March 11 2011

Ruby for Android development

This week I had the pleasure of speaking at the first ever Android Developer’s Conference in San Mateo. I gave two sessions, one on best practices in enterprise smartphone development (which seems to fill a gap and is always well-received) and another one on how to use Ruby to write Android apps. Rhomobile is not the mobile Ruby company – it is the mobile framework company. The value of Rhodes and RhoSync will still be there when (inevitably) all phones ship with Ruby. And we are working on efforts to make that happen. Nevertheless we are excited about the potential of Ruby to make smartphone development easier today.

I covered four ways to use Ruby to make Android development easier: how to use it for scripting, arbitrary app development, framework development and app integration via a server. For scripting, there is an interactive Ruby console (IRB) available for Android. You can download it here among other places. If you want to use Ruby the way you would use the Android Java you can use Ruboto. Its a nice way to highlight the power and elegance of Ruby even to do fairly direct reflection of the Java API approach to app development.

If you want to build an enterprise or informational app, consider using Rhodes. Rhodes uses a compiled subset of Ruby (by design) and is optimized for speed, code size and security. It provides the only Model View Controller framework for native smartphone development, as well as the only Object Relational Manager and app generator. Most importantly it lets you write your views in HTML and HTML5. So it leverages all of the goodness of styling libraries such as JQTouch, Sencha Touch and JQuery Mobile but for native app development. It takes the best of modern web development practices and applies them to native smartphone development.

Finally you can use the RhoSync app integration server to more easily integrate your Android apps with backend applications. It effectively removes the connection, retrieval, parsing and database management code from the device. And instead allows it to be done from a server, by providing a small Ruby class called a source adapter. A source adapter contains four methods: query, create, update and delete. The code size tends to be far smaller than the code you would write on the device to do app integration work (usually the majority of code in an informational smartphone app).

While the culture of Android development has traditionally been use of Java, there are many exciting ways to leverage the more modern Ruby language to do your Android development.