Saturday, August 23, 2008

I like Ruby - but big projects suck.

I like Ruby, I like it a lot, but I keep running into some issues. 

But first off let me say that for small programs, Ruby is absolutely wonderful. It is sad to see people struggle to write x10 or x100 the amount of code trying to do the same thing in Java because they don't know anything easier to use.

But then there are the huge projects. The ones with 50.000+ lines of code if written in Java and a fraction of that if written in Ruby. That is where the problems show up. Because even at 50.000 lines of code, a project is quite manageable in Java with a good IDE. With Ruby, 5000 is frickin bad.

I think some of the reason is because Ruby doesn't provide an easy way to maintain a project structure. Where a hierarchy is almost required in Java, it is actually outright hard to get it to work in Ruby. I don't particularly enjoy adding a header to every ruby file just to make sure it both can run stand-alone and compile properly with the rest of the project. Unit tests need even more path-magic to work.

The problem is compounded by the fact that you really would like to have well encapsulated libraries of code within a single project. In Ruby you sometimes write fiendishly clever and hard-to-understand code to simplify development in the rest of the code. Normally you'd then hide that implementation either as a separate jar/library/module, or at least in some (in Java terms) sub-package to insulate you from the implementation.

Unfortunately there are few ways to achieve that aside from building a full-fledged gem. And since there are no interfaces/protocols in Ruby, nor is it immediately clear from a class definition what public functions and methods your code actually provides, you probably are going try to read that code many times again, trying to understand exactly what it did, losing something like half an hour of productive work every time.

This problem could have been made smaller if rdoc was better, but when comparing it to say Javadoc, it is laughingly bad. Add to this the fact that rdoc is really lacking everywhere, both for ruby core classes and as for ruby gems, you should count yourself lucky if you find one with rdocs. So... again you are forced to read the actual code to understand how to properly use it.

Speaking of gems... this is yet another sad point compared to other languages. Jars and classpaths with Java suck, but at least you have your dependencies bundled up in a few files, whereas with gems you have them installed somewhere on your computer. This might be convenient for development, but not as good if you are writing something as a stand-alone program. Even c headers bundled with a library is a lot easier to get the hang of.

When I look at Python, which seems to have a sane module system and even docs bundled with the classes. I can't help but to wonder why Ruby hasn't borrowed these things already. 

Could it really be that most people still are only using Ruby for small projects?

0 comments: