iPhone Development with Ruby
I’m a Java and Ruby developer and I’m interested in starting development on an idea I have which would work great as an iPhone application. Naturally, instead of learning Objective-C I started doing some research on finding out if it’s possible to use another language for iPhone development. Here are some things I found along the way to answering my question:
[MacRuby](http://www.macruby.org/trac/wiki/MacRuby) seems like a good place to start. "MacRuby is a version of Ruby 1.9, ported to run directly on top of Mac OS X core technologies such as the Objective-C common runtime and garbage collector, and the CoreFoundation framework. While still a work in progress, it is the goal of MacRuby to enable the creation of full-fledged Mac OS X applications which do not sacrifice performance in order to enjoy the benefits of using Ruby". Version 0.3 has added some exciting features a core library called HotCocoa (talked more about below) and support for Interface Builder: "You can define classes, outlets and actions in a MacRuby Xcode project and they will automatically appear in Interface Builder."
[Dr Nic offers a project](http://drnicwilliams.com/2008/07/04/unit-testing-iphone-apps-with-ruby-rbiphonetest/), **[rbiphonetest](http://github.com/drnic/rbiphonetest/tree/master)** (formally called iphoneruby), to unit test iPhone apps with Ruby. In Dr Nic's own words, "I think this project can give Ruby developers a happy place to work from as they write their Objective-C/iPhone code. You still need to wire up your UI views and controller classes manually, but if you push all the “oooh that code really needs some tests” classes away from the UI-dependent frameworks then you can hook it up to rbiphonetest and write your tests in Ruby."
Apple has a page called “iPhone OS for Cocoa Developers”, which describes the differences between OS X and iPhone frameworks. Note that you will need to log in to the Apple Developers network to view the page.
HotCocoa is a layer of mappings on top of common Cocoa classes to make them simpler and to put them in line with idiomatic Ruby. The post, “HotCocoa is Pretty Damn Hot”, does a nice job of explaining how HotCocoa works and gives some simple examples of how to use it. For those interested, there’s an interesting debate about the merits of abstraction vs. simplicity in the comments section between the author, Why the Lucky Stiff (Shoes), and Rich Kilmer of HotCocoa.
In conclusion, the answer to my question about the ability of being able to write an iPhone app in Ruby seems to be “not yet”. It does seem that there is plenty of interest in this area and we’re starting to see new tools and frameworks pop up to help in this cause. They will no doubt make it easier to approach Mac desktop and iPhone development for people that are not familiar with Objective-C, Cocoa, and the other Apple frameworks.