A few days ago MacRuby creator, Laurent Sansonetti, released RubyMotion. It’s a set of tools that allow you to write iOS apps using Ruby, any text editor, and some basic Rake tasks, all while ditching XCode. I’m not going to delve into how it works, but instead will give a brief overview of my thoughts from a Ruby developer’s perspective, and what it means for the iOS and Ruby communities.
One criticism of RubyMotion is that iOS developers should not skip learning Objective-C:
RubyMotion is not a way to avoid Objective-c. Maybe you will not write it, but you have to be able to read it, because RubyMotion is hooked to the same runtime and Cocoa API. Guess which code you’ll see when you open the documentation? Unless RubyMotion is going to “port” all the huge Cocoa documentation (which is copyrighted) in Ruby format you definitely have to be able to read (thus learn) Objective-c. In this perspective RubyMotion just saves you some typing but does not allow you to skip learning Objective-c and Cocoa API. And no, there is no tab completion at the moment.
I agree with this premise, but come away with the opposite conclusion about RubyMotion. If you’re a Ruby developer and want to learn Objective-C, you should check out RubyMotion. The biggest roadblock to learning iOS for me was that I had to learn a verbose language at the same time as a plethora of APIs. After using Ruby for a few years, I’ve gotten way too comfortable with clean syntax, and something like this is just going to de-motivate me and push me back into my Ruby/Rails comfort zone:
Whether or not this lack of willpower makes for “bad” developer is a separate discussion. The fact is, to me, this code is intimidating. There’s a totally new API/application architecture and it’s in a very different-looking language than what I’m used to. I’ll speculate I’m not the only Ruby dev to feel this way.
RubyMotion lets me learn the iOS APIs with a language I’m already productive in. As part of the process, I’ve been reading plenty of docs and tutorials for Objective-C libraries. If I had a 10% chance of ever becoming proficient in Objective-C before RubyMotion, I now I have a 95% chance.
Rather than allowing iOS developers to avoid Objective-C, RubyMotion will be a gateway drug to the language. Avoiding Objective-C means sticking to Rails. Reading Objective-C docs and tutorials for the first time is the opposite of avoidance.
A RubyMotion developer has a lot to gain by learning Objective-C, as it enables him/her to read docs and source code, and eventually write or contribute to Objective-C libraries.
I write this keenly aware of the risk that that it’s dismissed as hyperbole: the next Rails-like hit in the Ruby community will be built on top of RubyMotion. We’re already seeing libraries that bring familiar patterns from the Ruby/Rails world into iOS via RubyMotion. Here’s a quick roundup:
BubbleWrap - A Swiss Army knife library that includes an HTTP client and a JSON parser/encoder. Allows you to do things like
Spry - Allows you to “Easily create a UITableViewController that leverages NSFetchedResultsController to fetch data”.
ParseModel - A thin Active Record syntax layer for Parse’s iOS SDK (disclosure: I wrote this). Synopsis:
Libraries like these could give RubyMotion developers a competitive edge over Objective-C developers. A RubyMotion developer has the choice to use any mix of Ruby and Objective-C librarie (s)he so desires.
There will likely be some tension between simply exposing existing iOS APIs and wrapping/abstracting them away. It will be very interesting to see how this plays out. I’m not sure what the right answer is, or even if there is a right answer.
One of the big wins of Ruby is metaprogramming. RubyMotion lacks some functions like
class_eval. Another area that needs work is dependency management, as RubyMotion does away with
require. I have confidence the RubyMotion team will iron out these issues, but they still are worth mentioning.
RubyMotion is the most exciting Ruby software I’ve encountered. It opens up an entire world of iOS development to me. I’m sure it has done the same for others. More Rubyists will likely learn Objective-C and actively participate in the iOS community. RubyMotion thus far is a win for Ruby and Objective-C devs alike.Alan 08 May 2012