Sunday, April 09, 2006

More Observations about Ruby and Rails

I've been sick for the past few days and it's given me the opportunity to play around some more with test-driven development in rails. My overall conclusion is that ruby is a very interesting language, and the rails active-record approach looks very promising, but I am not sure I would actually recommend this technology for a production system, at least not yet. Here are some pros and cons:

Good points:
  • Ruby syntax is clear and simple, a joy to work with. The shortcuts for attributes, parenthesizing arguments to methods, passing in hashes as parameters, the simple use of 'end' to close blocks of code, and other such ideas really pop when you start using them.
  • Mixins seem to be a very nice compromise between the single inheritance of Java and the multiple-inheritance madness of C++. Again, the way they are implemented in Ruby is very nice and clean
  • The Rails active record pattern and the built-in testing framework encourages test-driven development and makes it very easy to develop a clear model. Mixins make it very easy for only the true domain-level code to show up in your model. The rest of the framework functionality is just there
  • Only database schema changes require rails to be restarted. Otherwise, you can make any change you want in the code and run the app! It's a vast improvement over JSP, that's for sure!
Weaknesses:
  • Running tests seems quite slow. 17 unit tests took 3.7 seconds on my 1.6MHz laptop with 512 MB of RAM
  • I found that it seems as though rails might run each unit test concurrently which can cause weird problems if you are doing a lot of set up in your test rather than in the fixtures
  • So far there is no direct step-along-through-the-source-code debugging in any IDE as far as I can tell
  • So far there is no IDE-supported refactoring as there in Eclipse and Idea
  • Because Ruby is a dynamic language, even simple syntax errors are only identified at runtime. In practice, this means you really have to write your code test-first. Even so, it is annoying to have to run tests just to find out that you forgot to pass in a parameter to a method.
  • I presume this is also because Ruby is dynamic, but as far as I know, there is no built-in code completion yet.
  • This is not necessarily the fault of Rails, but still, I have a feeling that many developers out there will end up putting a bunch of business logic right into the views and controllers. This tends to be a problem in all languages and frameworks, with people simply not putting code in the domain where it belongs, so I don't know if it's fair to say it's a major fault of ruby, but nevertheless, I bet it will happen if Ruby and Rails take off
  • Having used them a bit, I don't know how I feel about blocks and closures. On one hand, they do let you effectively create domain-specific languages, e.g. see the Rake configuration. On the other hand, I have a feeling this kind of thing can easily be taken to dangerous extremes.

2 comments:

Jeff Perrin said...

I'm tempted to agree with you, but since you have *flowers* for bullet points I'll just mark this post down as the rantings of an Amero-Canadian-Russian Hippie lunatic.

jonathankohl said...

Might defeat the purpose, but how about using Rails for the front-end, and Java in the middle tier?