Building an App using HTML5 & JavaScript

Coming from C++, Java, Perl, Python and JavaScript background for OOP I just couldn’t take Objective-C. I think there are a good set of libraries and Objective-C also has a good set of language level features but the syntax is the annoying part. Half-heartedly I have been going over a bunch of documents from Apple.

Then I came to know of PhoneGap. It provides a framework to write the app using HTML5 and JavaScript. Then I decided to give it a try. I had the app working in a two days and could see it in action in the iPhone Simulator.

Then I read about the dreaded 10.6 ios rejection on the forums and that’s when I realized that while I do have a working app, it doesn’t feel native.

That’s when I came to know about JQueryMobile. The way HTML is written for JQueryMobile is completely different from the normal HTML. It actually makes use of the data- attributes of HTML5 to control various aspects of the rendering and navigation.

Switching to JQueryMobile realy made the app to shine and look very native for the transitions and the UI components. There are even css themes designed specifically to look like iOS LAF and after adding that as well, my app just looks and feels native!

I think the approach of developing apps using HTML5 and JavaScript has a lot of potential. For one, it allows to write the app once and run on multiple OS platforms such as iOS and Android. Ofcourse, there are device specific features like the camera, accelerometer, gps etc and PhoneGap (or other similar frameworks) typically provide JavaScript wrapper APIs so the developer doesn’t have to know the native APIs. I also like the fact that PhoneGap tries to base their APIs on the W3C standards where available (for example Storage and File).

There is one and only thing that is a pain with PhoneGap development (I think I should actually say Cordova). The javascript calls to the native APIs are asynchronous. This is a real pain. For example, if you have a set of app preferences that have to be read at the beginning of the app, then it requires chaining a lot of async calls together to get all the values. That’s when I came to know about the concept of Promises in JavaScript but it still doesn’t look promising (no pun intended) for someone who just want to feel like writing a regular synchronous call.

I don’t know the exact reason why these JavaScript to native app calls have to be asynchronous. Apparently a url with protocol of gap:// is used to handle this type of calls that require it to be asynchronous. I wonder if there are other ways to do it synchronously.

Anyway, the simple I app I have just has one such app level preference and for now it isn’t too much of a pain, but if I were to work on a more advanced app, let’s see how that goes.

This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.