citizen428.blog()

Try to learn something about everything

Ruby Implementations and Why We Should Care

Not too lang ago our favorite language had only implementation, the one made by Matz (now commonly referred to as MatzRuby or MRI). This has changed quite a lot lately, so I decided to give you an overview of the various Ruby interpreters I use, why I use them and why they also might be interesting for you.

  • Ruby 1.8.6: This is your trusted old Ruby 1.8.6, and while it may not be the most spectacular of the implementations listed here, it’s the most widely used Ruby interpreter around and the current de facto standard of the language.
  • Ruby 1.9.1: Featuring the new bytecode interpreter YARV, this is the newest ‘official’ Ruby version which gives us interesting features like improved speed, block local variables, a new lambda syntax, native threads and some other niceties. So while we are waiting for 1.9.1 to replace 1.8.6 as the standard Ruby interpreter (which probably will take quite a while), my advice is to install it now, play around with it, get used to the new things and help the community in porting gems to 1.9.
  • JRuby: A Java implementation of Ruby, which allows developers to interact with Java classes or define them from within Ruby. It’s fast, it works well, and is a big driving force in the filed of alternative Ruby interpreters. As of now I mostly used JRuby from within “ruby-processing”:, but eventually want to have a look at Monkeybars, which was created in order to simplify the development of Swing apps with JRuby.
  • Rubinius: Here is what the project itself has to say about its relevance for Ruby developers: “A spec driven Ruby implementation. A core library written in Ruby. More first class objects than you can shake a stick at. Super easy to contribute. Low barrier to entry. If you can breathe, you can commit”. So far I only used Rubinius to test some of my own scripts, but eventually would like to find the time to contribute to the project by writing new specs or trying to fix failing ones. I encourage you to do the same, since this is not only a great chance to learn more about Ruby’s internals, but also to help the Ruby community at large.
  • MacRuby: MacRuby is a port of Ruby 1.9 which sits directly on top of OS X core technologies. This means that when you e.g. create an Array, you get an NSMutableArray (see the output of Array.ancestors in macirb: [NSMutableArray, NSArray, Enumerable, NSObject, Kernel]). It also features HotCocoa which provides mappings for common Cocoa methods thus making your MacRuby programs a lot more idiomatic. This together with the interactive way of development provided by macirb make MacRuby an interesting tool not only for Ruby developers, but also for people who want to prototype their OS X apps.
  • Shoes: Some people may be surprised to see Shoes in this list, and technically they are right. Shoes is not a distinct Ruby implementation, but it is a Ruby distribution (which will switch to 1.9.1 in Shoes 3), which lives separated from your other Ruby interpreters, installs gems in its own location and so on. The main thing though is that Shoes provides us with an easy to learn and use, cross-platform GUI toolkit that makes developing in it fun! Granted, it may not be suitable for everything, but with a bit of creativity you can push it quite far. Have a look at the Shoebox to see what people are doing with it.

There are of course other Ruby implementations like Cardinal (a Ruby interpreter for Parrot), IronRuby (Ruby for the .NET environment) and tinyrb (a tiny and fast subset of Ruby), which I won’t describe here in more detail, since I haven’t yet had time to play around with them.

So why should we care? Because the various implementations create a sort of competitive spirit, therefore pushing the limits of Ruby and driving it forward, by making it faster or running on top of other VMs (JRuby, IronRuby), thus letting it leverage a plethora of established technologies and also exposing it to potential new developers. Plus we also got RubySpec, so potential Ruby implementors have a standard to follow.

I hope you enjoyed this post, please leave comments in case you disagree with something or want to add some information!

Comments