Rhodes is a new open source solution to bring Ruby development to mobile devices. Even more: it allows to use a single Ruby source across many devices, currently iPhone, Windows Mobile and RIM's BlackBerry, with support for Symbian and Android to follow soon.
The chance to deploy to the iPhone should be interesting, as it adds another option for iPhone development (next to Objective-C). Also: Rhodes and all it's necessary interpreters and libraries are open source, hosted at GitHub, a public bug tracker for Rhomobile's projects is also available.
We talked to Adam Blum of Rhomobile about how exactly Rhodes works, and how they managed to get Ruby as a language for the iPhone.
The Platforms
The first question is of course about how Rhomobile made it possible to write Ruby apps on the iPhone. Adam explains:
The answer is [..] we do bundle the developer's app with our framework and a Ruby interpreter. To be compliant on the AppStore app developers can't be downloading interpreted code on the fly from elsewhere. It is the app developer's responsibility to be abiding, and if they do want to be violating there are much simpler ways to do it than embedding a Ruby interpreter and downloading Ruby code from elsewhere.
The Ruby used on the iPhone is a recent Ruby 1.9 version. Rhodes supports other platforms and plans to add more platforms where Ruby is available, for instance Symbian.
Supporting Rhodes and Ruby on the BlackBerry, where applications are written in Java, required a bit more effort. Rhomobile chose an ambitious solution that uses XRuby. XRuby is a Ruby version for Java which compiles Ruby code to Java class files. Development of XRuby has slowed in the last year, but Rhomobile has taken XRuby, improved it, and is now using XRuby to run Rhodes applications on the RIM BlackBerry. Adam also mentions:
We are working on Android, starting from our own Ruby that we did for the RIM implementation (which is based on XRuby not JRuby)
Adam also mentions the need to keep the Ruby interpreters small, which has an effect on the supported Ruby libraries:
It's definitely a subset. This is part of the reason for the need to do our own framework. We do a bunch of things to make it smaller and will continue to do more over time.
Some features, such as the eval()
are also not supported.
Since Rhomobile works with Ruby interpreters for mobile platforms, we asked Adam what he'd like to see to support that:
Hmm... we'd like to see Ruby implementors focused on making smaller implementations of Ruby plus more attention to the size cost of dependencies when people build useful add-on Gems. But for now that's sort of our job to do and that's OK too.
How it works
Rhomobile aims to support many different mobile phone platforms, so they chose a way to build the cross platform applications Rhodes framework. In short: Rhodes applications are web applications that run locally on the phone (ie. the Ruby part of the application runs on the phone as well as the HTML GUI). The GUI of these applications is defined as HTML and displayed using the browser component that's available on all the phones. Modern phones tend to have standard browsers, eg. the Webkit based Safari on the iPhone, which means that it's possible to use normal web development methods to define applications, including using Javascript in the GUI. Rhodes also takes care of making the GUI look like native GUI components on the individual platforms, eg. by using IUI on the iPhone GUIs.
But Rhodes adds another twist to this: some of the advanced features of modern smartphones are available to the Rhodes applications. Currently available is geolocation information; access to the accelerometer, camera and to the local PIM will be available in the next version due in January.
It's possible to access these features with Ruby calls and as HTML tags in the HTML files, eg.:
<geolocation/>
will be shown as something like this :
37.3317° North, 122.0307° West;37.331689;-122.030731
Starting work on a Rhodes application is as simple as with many other Ruby web frameworks, it starts with a generator:
rhogen app accountapp
This generates the basic application skeleton, with controllers and other apps. More information is is available in the Rhodes Tutorial.
Another part of Rhodes is Rhom, an object mapper. Rhomobile also has other libraries on GitHub, eg. Rhosync, which helps with synchronizing various data sources to the mobile phone.
Rhomobile's projects are rather new - the current release is at version 0.1, but a 0.2 release will be out by the end of the month with improved PIM access and GUI. A 0.3 release is expected to be out by late January 2009 which should bring support for more platforms, access to more device features (accelerometer, etc), as well as project hosting for Rhodes developers.
Finally it's important to mention the Rhodes projects are open source and hosted at GitHub. Rhomobile's business model builds on dual licensing. Rhodes applications are open source, but if a company wants to use Rhodes but keep its source closed, it can do so by getting a commercial license from Rhomobile.
Do you know of other cross platform solutions like Rhodes which offer a similar level of integration? Would you use Rhodes for writing an application?