September 23 2011

“hybrid applications” and Rhodes

As most of you know Rhodes was created to enable building native smartphone applications using web development skills: HTML, CSS, JavaScript, Ruby and the general modern Model View Controller pattern.   We often get the question “oh, so you build hybrid apps“.   While frameworks that you let write HTML and still end up with a native app sound like they might be “hybrid” (of native and web), that isn’t the original meaning of the term “hybrid app”.

So What Is A Hybrid App Anyway?

In fact the term hybrid application refers to creating a native app shell or stub on the device,  framing a webview component, where most or all of the application pages and functionality is delivered live as a web page.  The term “hybrid” refers to the user experience in the app.  They have some aspects of native apps: they can use device capabilities and access local data when appropriate.  But much of the app functionality and content is determined by the web page that the app is connected to.

How Do You Write A Hybrid App?

Hybrid apps can be written with any number of technologies and frameworks. You can write them in Objective-C for iPhone.  For example, a tab bar at the bottom and a UIWebView framed on th page.  The UIWebView control is set to point to a page which has appropriate links that determine how the app is navigated and behaves.   You can write the same thing with a framework like Rhodes or PhoneGap as well of course.   Both of these frameworks use HTML pages for their content, generally locally on the device.   They of course have the ability to point to external content on a backend web app as well.

So Which Is Better A “Hybrid App” or a “Native App”?

Frameworks like Rhodes do not really take a position on whether it is better to have code and logic executing on the device or remotely on a backend web server.  But some (not all) of the purpose of doing a hybrid app is removed when using a framework that supports HTML for building native apps,  since part of the value of the web app having the logic is the ease and portability of coding in HTML.  Rhodes (and PhoneGap) both give you the capability of using HTML and still have a true native app with all code running locally, data available locally and full device capabilities available in every part of the app.  Apps with local code and data tend to be significantly faster.  And of course they don’t need a live connection at all times. So, all else being equal, and given a way to harness the power of web programming for building native apps, we at Rho believe that native apps are far more useful in most situations.

So When Is A Hybrid App Better? 

Given that that incentive is removed when does it make sense to have a hybrid app, written with Rhodes or with any other framework or SDK? Hybrid apps push the app logic (or much of the logic) to the backend web application. It is easy to change and update app functionality without pushing out an app update to the device.  The fully native app (written with Rhodes or Objective C or another framework) would need to be updated to get the functionality.   If you have some kind of app management capability like RhoGallery or a mobile device management solutions like Good, Sybase Afaria or Mobile Iron, this is also less of an impediment.  There are some scenarios however where apps have to be changed often and they don’t want to deal with app updated. Hybrid apps can be useful there.

How Does Rhodes Help In Building Hybrid Apps?

Rhodes allows you to write hybrid apps by just linking to an external URL from your Rhodes views.  When using remote pages access to device capabilities is via JavaScript calls or extended HTML tags (e.g. <geolocation>) instead of Ruby calls that would normally be made in a Rhodes controller.  These JavaScript or HTML extensions of course need to be embedded into these remote web pages.  Currently we only support a few operations as HTML extended tags, but over the next few months we will add support  for popular methods of performing HTML and JavaScript calls from web pages.   And of course you can “go local” whenever you want by including content that is linked to local templates on the device.   Thus you can always have the best of both worlds of ease of deployment of “hybrid apps”  and the fast execution and ability to run offline of “local” apps.

Rhodes: The Right Framework for “Hybrid Apps” or “Local Native Apps”

In summary Rhodes is the ideal environment to write hybrid apps from.  You can easily point to “live content” out on remote web applications  from your Rhodes controllers.   But more importantly you can use your web skills and the productivity and portability that they afford to write true native local applications that run on the device.