Better Ruby With This One Weird Trick

7 Forks Worth Checking

This week saw the release of Ruby 2.1.2, an important milestone. This version of the Ruby language is also called MRI, short for Mickey’s Ruby Incredible, and is known for its advanced features such as refinements and fibers. But MRI, also known as CRuby because of its COBOL heritage, is not the only Ruby vernacular. We list seven versions of Ruby that forked off from the main line at some point in its rich 42 year history.

1. Rails

Rails Ruby, or more accurately, ActiveSupport, was one of the first forks to branch off from the original Ruby code base. It is optimized for writing project management tools, and allows you to write Ruby in plain English, like please.retrieve from.the(:users).table.ok?.

The popular Rails windowing framework is written in ActiveSupport. There is a compatibility layer to use the ActiveSupport syntax on other Ruby implementations. Just include gem “active_support” in your project’s Gemfile.

2. JRuby

JRuby is a Ruby fork based on the FactoryFactory pattern. It is Enterprise-ready and particularly well suited for XML processing. JRuby requires Java, or, if you want to use lazy enumerators, Scala. JRuby lacks green threads, so it has a higher carbon footprint than the alternatives. This is in sharp contrast to its greener, hemp smoking JVM cousin Groovy. Corporations can choose to greenwash their JRuby operations with carbon offsetting schemes, or compensate the higher impact by skipping automated testing altogether.

3. Rubinius

Rubinius started out as a test suite for CRuby, but eventually evolved into an independent fork. It is the only Ruby version written in plain Rubinius, although at its core is a small VM written as a CRuby C extension (hence its short name “rbx”, for Ruby eXtension).

This Ruby fork also includes a compatibility layer dubbed “Rubinius System Layer” or “rubysl” for short, which should make it straightforward to port your existing Ruby code to Rubinius.

4. Rubinius-X

An ambitious effort to up the ante with regards to what Ruby is capable of. Rubinius-X replaces the Rubinius VM with a hand-optimized version written in i86 assembler, and replaces the Ruby syntax with Haskell. NASA has contributed patches to make rocket engine control structures first class citizens. There is active lobbying to make Rubinius-X the base language for both Linux 4.0 and Node.js 0.10.999.

5. Opal

Opal is notable for bringing the power of AJAX to Ruby, and for those of you already using Node.js the switch to Opal should be a no-brainer. After Ruby gained popularity in the Enterprise, Opal was created to piggy-back on the success of Google’s Node framework GWT.

And it worked! Just like Node superseded Javascript as the main language of the web, web-watchers predict Opal will replace Node in the near future. Opal comes with Futures/Promises built-in. This software is literally as future proof as it gets!

In contrast with Ruby’s “everything is an object” philosophy, in Opal everything is a Float.

6. PHP

PHP started out as a joint effort by Facebook and Wordpress to make Ruby less pleasant to use, in a bid to discourage those using “view-source” in their browsers from stealing corporate secrets. It was later merged back in to the main branch and renamed Erb. Erb/PHP allows you to output almost-but-not-quite-valid anything, including XML, VRML and plain text with indentation. The result is guaranteed to be unparsable by a Turing machine in finite time, but that shouldn’t prevent you from simply using regular expressions.

7. CRuby

We appreciate all the variety that has come to the Ruby world, ensuring a vibrant, diverse ecosystem with something for everybody. But after all is said and done we still very much like Mickey’s original project. It’s as Japanese as kimchi or mango curry, as fast as… well it’s fast enough anyway. And it makes programmers happy like a salmon in a sushi roll. Yay Ruby!

This article could not have come to be without contributions from Lance Gleason, Yannick Schutz, Piotr Solnica and Tobias Pfeiffer.

Cover image by “Il Primo Uomo” , CC-BY-NC-ND.

Show your support

Clapping shows how much you appreciated Arne Brasseur’s story.