November 30th, 2007

This could possibly be one of the best Christmas’s ever, as Ruby 1.9 is slated to be released in the near future with a host of new features and performance improvements.

The performance improvements are extremely impressive and will be a huge boost to Rails applications – I am really looking forward to them. Not only will your Rails apps load faster, but they’ll take up less CPU resources on your system, which means less servers for large applications, meaning big cost savings and less headaches. For smaller apps, your server will be able to do more before you need to add a second, or can host more apps.

It won’t be an easy migration though: Ruby 1.9’s features include many things that will break the Rails framework and Rails apps. Here are just a few that caught my eye:

  • #send will no longer ignores visibility (i.e. private methods), you must use #send!. (Of course, you could re-define #send to call #send!.)
  • Class variables are no longer inherited.
  • Hash#to_s returns something more intelligible, but breaks anyone relying on the current behavior of mashing all the key-value pairs together.
  • Hash#each now passes a two-element array.
  • ?c no longer returns the ASCII value for c, but instead the single-byte string "c" (you must use String#ord to get the ASCII value). Behavior for String#[] and String#[]= changed similarly, so "foo"[1] == ?o will still return true.
  • String is no longer an Enumerable, so String#each has been removed (use String#each_char instead).

But, there are many, many benefits. A lot of the improvements Rails made to Ruby through its “core extensions” library have landed in Ruby 1.9 (my favorite: the Symbol#to_proc implementation is in). Rails 1.9 has real character encoding support, more meta-programming methods, and plenty of other cool wizardry. Check out those new features for yourself.

Leave a Reply