Bubble Foundry


On PhoneGap

by Peter.

My friend Marston asked last night if PhoneGap was a better solution for cross-platform mobile app development than Rhodes. We ended up discussing PhoneGap a bit and I thought it would be useful to share it here:

Marston: I’m looking at both solutions, but am leaning toward PhoneGap as it seems to be more complete and has a good future roadmap.

I’m thinking of using it for some general apps, less about all sorts of fancy gps + gyroscope + 3d uber gaming apps.  More for mobile apps to integrate into web app API’s etc.

I’m obviously looking to use it because it supports so many platforms.  How has you found it so far?  I guess the other main thing I’d love to hear is what limitations, bugs and overall #fail you’ve run into with it.

Me: If you have the time to learn a native platform, do that. You’ll get better performance, particularly drawing user interfaces and processing any sort of noticeable amount of data (ie maybe 100+ kb).

That being said, you want a cross-platform framework the benefit of those that compile to native code isn’t as cut-and-dry. I’ve never heard of Rhodes but it sounds nice. Titanium is very popular with some developers and seems to work quite well on iOS but I’ve heard that their Android support lags a lot. Generally, and this is the reason why Apple doesn’t like them (though they don’t seem to be rejecting Titanium apps [oh, and PhoneGap is basically unofficially officially blessed]).

PhoneGap is near and dear to my heart. I haven’t used it THAT much but I am using it all this week and did two years ago for the Smakelijk Amsterdam app for Het Parool. You’re just in a WebView, so you only have Javascript and CSS. The iPhone WebView is very good (consistent, hardware accelerated CSS3 transitions and animations, etc), the Android one, not so much (2.0+ is noticeably better than earlier versions). However there are basically PhoneGap branches for every platform (including experimental ones for OS X and Windows), meaning it works a lot more places than, say, Titanium (again, I can’t comment on Rhodes). Also, PhoneGap cleaned up their device APIs about a year ago and now follow all the (proposed) W3C specs, so you’re kind of future-proofed.

If you want to just play around with third-party APIs I would recommend going with PhoneGap. While a PhoneGap-based web app won’t be the greatest for games (though I’ve seen some great ones, so it’s getting there!), you can do GPS or gyroscope apps just fine using PhoneGap. It also gives you a ton of other device APIs (http://wiki.phonegap.com/w/page/16494820/Roadmap). One thing to know is that cross-site XMLHttpRequest restrictions are NOT enforced for local Javascript, meaning that you actually can do API requests to remote sites. For instance, I’m building a demo app for Mediamatic right now in PhoneGap that will fetch OAuth credentials and then do signed API requests all within the WebView. Pretty cool stuff!

Oh, and just because you’re making a PhoneGap app doesn’t mean it’s cross platform if you don’t actually test your Javascript and CSS on multiple WebViews. Sore point this week. ;-p

Marston: What are your thoughts about combining something like phonegap with a framework like JQTouch (http://jqtouch.com/) or Sencha Touch (http://www.sencha.com/products/touch/)?  I see them listed on the PhoneGap tools page.  Or is there native functionality in phonegap which takes care of this and makes it easy to make really nicely design frontends?

Or would those frameworks be semi-competitors to PhoneGap and have overlapping functionality?

Me: PhoneGap is a native code wrapper that provides ways for Javascript to interact with the device, so it doesn’t have much (any?) overlaps with UI frameworks.

Sencha Touch is based upon JQTouch (and ExtJS) and was the cause of my miseries the last few days. It’s really slow on most Android devices and is generally very heavy and verbose. Only on the Samsung Galaxy S and Galaxy Tab (the tablet!) did it run well. Oh, and Sencha is NOT an open source library: there’s a bunch of bullshit about licensing and forum access and such. JQTouch is quiet these days as the founder got hired to write Sencha but apparently there is a new lead developer.

jQuery Mobile, on the other hand, looks quite nice. It’s part of the official jQuery project and it doesn’t seem too large (yet). iUI is old but still popular, and I know some of the PhoneGap guys have made some decent minimal UI frameworks that are listed on the tools page (MagicFramework, maybe?).

But yeah, if you’re going for that native look you’re going to want some sort of UI framework, if nothing else to mimic fixed position title or navigation button bars – fixed positioning isn’t possible on mobile and has to be hacked – you want a framework to avoid writing that code yourself.