I’m pretty annoyed with Ruby right now. At least I feel that way. Looking a little deeper I realize the source of the annoyance is, like usual, my own shortcomings. My friends and I embarked on a software project a while back. I helped talked the group into using Ruby on Rails as the framework over choices like Java or .net because I was excited about it. Many had reservations. Today I’m annoyed at myself for not listening to them more.
The biggest problem with an uncompiled language is that there’s no compiler to tell you when you’ve screwed something up. The incredible power and flexibility you get from Ruby’s loose dynamic typing and mixin inheritance style means that the IDE and compiler really have no idea what’s valid when you type it. Compare this to Eclipse for Java or Visual Studio for .net where once you type ‘objectname-dot’ there’s a list of valid methods you can call and what kinds of parameters they take. If you get it wrong, there’s a red squiggly underline saying something is wrong before you’re on to the next line of code.
Yesterday 3 reasonably good software engineers took a solid 3 hours to figure out that we were passing the wrong class of argument into a method. The problem was exacerbated by the behind-the-scenes magic that Rails does to try to make your life easier. We were passing a Tmail object into ActionMailer.receive, which might seem to make sense since the receive method that everybody who uses ActionMailer writes expects a Tmail object as an input. But we had forgotten that you’re not supposed to call this method. In fact ActionMailer makes it impossible to directly call the method we wrote. Instead you’re forced to call the class method, which we had forgotten expects a string as input that it parses into a Tmail object for you. And like usual, the error message is useless. Bad error messages are the single biggest flaw with Ruby on Rails IMHO. (Maybe just the easiest to fix compared to the other problems.) This was particularly frustrating because we spent an entire day tracking down something that any strongly typed language would have caught instantly.
For a long time, I’ve argued that people should use the highest level programming language they can afford to. A huge advantage of pointerless languages is that you can’t make pointer mistakes. It’s simply not possible to write that kind of bug in the higher level language. Coding therefore become faster and more reliable than in a lower-level language. The only cost is run-time performance, and if you’re writing server code as most of us do these days, then scalability is generally not limited by performance. I had assumed that this analogy would continue from managed-code languages up to the hottest new scripting language that seems like it’s flexibility might fulfill OO’s promise of code re-use. Today I’ve changed my mind. Ruby is not a higher level language than C# or Java.
Conceivably, a really good IDE could make up for a lot of this. But due to the run-time binding in Ruby it would never be perfect. When selecting a development system, generally I think the language itself is really unimportant compared to the quality of the tools and libraries available. OO languages are generally about the same. But IDE’s matter so much. And libraries determine how much you have to write yourself vs. using what others have done before you.
A friend asked me if I was writing this as a warning or a cry for help. It’s both. It’s a warning about the scalability limits of Ruby. Many people intuitively suspect that Ruby on Rails won’t scale well, but they confuse the different types of scalability. The most common complaint about Ruby is that its runtime performance is too slow to scale well. As Cal Henderson’s wonderful book
on website scalability points out, raw performance does not matter if you can add more servers, which you can with RoR. But as I learned yesterday, Ruby on Rails does not scale well in terms of complexity. A friend once aptly pointed out that 43 things was the largest site anybody had managed to build in RoR to date. The current state of tools and libraries and aspects of the language itself make it extremely difficult to write and maintain large complex projects with many developers.
It’s also a cry for help, but not for our particular project. You’ll see it soon enough. It’s a request that if you’re working on Ruby or Rails, please invest in the tools and the robustness of the libraries. The error messages in Rails are total crap, as I’ve mentioned a couple times before. And the IDE’s really need to improve if the framework is going to see major use beyond hobbyists.