Developing apps for Mobile Device in Ruby

May 2, 2012 -

There has been a lot of buzz within the community lately about upcoming releases of Ruby implementations to mobile devices and I am no less excited than anybody else. Anything that would get me away from that freakin’ Objective-C is welcome.

The first step towards this is the mruby project which I will quote here:

“mruby is the lightweight implementation of the Ruby language complying to the ISO standard. mruby can run Ruby code in ‘interpreter mode’ or ‘compile and execute it on a virtual machine’ depending on the developer’s preference.”

So far though, the mruby is only in its prerelease state but the source code is public for anyone that wants to look closer or submit thoughts and ideas.

The next step will be the MobiRuby project which takes advantage of mruby. They state that the goal of this project is to replace Objective-C, C and Java on the mobile platforms. The first target is the iOS platform and Andriod will be the next runner up.

The release date for MobiRuby will be sometime late spring or summer 2012 and I for one can’t wait to play around with it.

So just to give you some example of what this will be like, here is a comparison of syntax for the basic function of creating an alert.

In Objective-C:

UIAlertView *alert = [[UIAlertView alloc]
            initWithTitle: @"Hello"
            message: @"I'm Objective-C"
            delegate: nil
            cancelButtonTitle:@"Not again..."
            otherButtonTitles:nil];
[alert show];

And in MobiRuby:

alert = UIAlertView._alloc \
  ._initWithTitle _S("Hello"),
  :message, _S("I'm MobiRuby"),
  :delegate, nil,
  :cancelButtonTitle, _S("Finally!"),
  :otherButtonTitles, nil
alert._show

I know it’s not really less code for this example but just looking at the ruby syntax is sooo much nicer in my opinion.

And finally, I just want to reference a talk that Matz himself did just recently. Here it is.

Part 1

Part 2