InfoQ

News

Rhodes Brings Ruby Apps to iPhone, Windows Mobile, BlackBerry

Posted by Werner Schuster on Dec 16, 2008

Community
.NET,
Ruby,
Java
Topics
Rich Client / Desktop ,
Runtimes
Tags
Android ,
XRuby ,
Symbian ,
iPhone

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?

I can put down my Cocoa book by Nilanjan Raychaudhuri Posted Dec 16, 2008 9:37 PM
Any iPhone Apps Yet? by Stefan Tilkov Posted Dec 17, 2008 12:27 AM
Re: Any iPhone Apps Yet? by Adam Blum Posted Dec 17, 2008 12:04 PM
  1. Back to top

    I can put down my Cocoa book

    Dec 16, 2008 9:37 PM by Nilanjan Raychaudhuri

    This is really cool. Cannot wait for the next version with accelerometer and camera support.

  2. Back to top

    Any iPhone Apps Yet?

    Dec 17, 2008 12:27 AM by Stefan Tilkov

    Are there any iPhone apps yet that have been built using this? My main worry would be that Apple rejects an application that has been developed using this toolset because of some stupid reason (as they've done in the past).

  3. Back to top

    Re: Any iPhone Apps Yet?

    Dec 17, 2008 12:04 PM by Adam Blum

    Stefan,

    We have no way of knowing all the apps people have built with our stuff. But we have some developers that we do know are releasing apps soon on the AppStore. We'll keep you guys (InfoQ) updated on that.

    - Adam

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.