InfoQ

News

Rhodes Brings Ruby Apps to iPhone, Windows Mobile, BlackBerry

Posted by Werner Schuster on Dec 16, 2008 07:59 PM

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

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

Bindings, Platforms, and Innovation

This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.

Orchestrating Long Running Activities with JBoss / JBPM

This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.

Neo4j - The Benefits of Graph Databases

This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.

Realistic about Risk: Software development with Real Options

This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.

Communication Flexibility Using Bindings

This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.

Writing DSLs in Groovy

After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.

Scaling Agile with C/ALM (Collaborative Application Lifecycle Management)

IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.

Concurrent Programming with Microsoft F#

Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.