Would you use PhoneGap again?

von

I was invited to the Mobile Forum Stuttgart and speak about Apache Cordova/Phonegap (great conference, check it out next year!).

There is a lot of interest in Cordova these days. It’s understandable: with thousands of platforms around it is hard to build a mobile app for all of them. Actually it reminds me on the days when we all spoke about the “browser wars”. The browser war might be history. Today it is the platform wars and it is worse than before. Apache Cordova is said to be one answer to the platform problem. It makes it possible to write a native looking app with just HTML5 and JavaScript. But wait a minute - is it really native looking? In my talk I highlighted what you can do with Apache Cordova. It is great and feature richt. But I also found some drawbacks, from my own experience when coding the apps for Time & Bill.

** Apps with Apache Cordova and Phonegap ** from Christian Grobmeier

For Time & Bill, I needed to get started quickly. I was looking into Android development and into iOS development. While I found Android being very easy for me as Java developer, I didn’t grow into iOS so quick as I would need it. For me PhoneGap / Apache Cordova was a savior before 2 years.

After the talk, I was speaking to a couple of devs. One of them asked me:

Would you use Cordova again, if you would have objective-c skills?

But I was not so sure if I would.

Don’t get me wrong: I totally enjoy working with Apache Cordova. It’s easy. But don’t expect to start with Cordova and have a native-looking and native-feeling app on your device in an instant. I haven’t expected that, so I was happy.

The biggest misunderstanding with Apache Cordova is that it does everything for you.

But it’s not the case. It is just the base for your application. It supports you to package your app and helps you to access device features like the camera. Nothing more. There is nothing in Cordova which helps you to organize your App in terms of for example MVC. It’s not an application framework. You need more. You need help from the Apache Cordova ecosystem. And with ecosystem I mean everything which helps you to build mobile ready websites.

For example, there is jQuery mobile. It is a framework which lets you organize your app and even comes with a nice look & feel. It’s pretty straightforward to start with it. But it has some drawbacks. The look & feel is simply not the one you expect on your device. It’s neither Android nor is it iPhone. Also the behavior is not exactly what you would expect. It’s different, it’s a jQuery mobile experience.

Also I found it is extremely sluggish on my older devices. Especially when it came to page switching. No doubt, it is very nice and you can do nice things with it. But it was not was I was looking for - it was too much.

Then I was looking into Sencha Touch. I cannot say I have much experience with it, but the development model felt very unusual for me. Sencha does also come with a Look & Feel, but again, it’s the Sencha Look & Feel, not the Android or iPhone one.

Screenshot

Finally I wrote Roadcrew.js. It does nothing else then page switching. I liked how it was done in jQuery mobile but improved the way to intercept the page switching (for my taste and compared with an older version of jQuery mobile, namely 1.0x. Not sure if this has been improved in recent versions). This could have been done with Angular.js too. I used Roadcrew.js, because I was unsure if Angular.js would give me the performance I need on older devices. I didn’t want to make another experiment.

I am still happy with Roadcrew and writing a jQuery/Zepto.js based app on Cordova. Except it still doesn’t look good. I have started on reworking the whole app, but at the moment it’s still the ugly interface. While functionality is OK, it’s really looking more like a web page and not like a mobile app. To overcome this I have looked at Chocolate UI. And I looked into Ratchet too. Both frameworks give you a look & feel. Chocolate looks more like Android, Ratchet looks like the iPhone. Both are fundamentally different how they work. It’s simply not possible to use them exchangeable, so you have to create two apps. Of course, that’s not possible. I have withdrawn both experiments with the two.

Both had a lot of issues too.

Now I started to download the Android styleguide and create my own CSS for the components I need. This is of course cumbersome. I have to do the same with iPhone styles later. All of that is simply there when you go native.

Something else is often missing. Just because you have a nice looking button does not mean the button behaves as expected. You face several problems. One can be solved with implementing the FastButton for your system.

Let me quote an Google engineer:

The problem with this approach is that mobile browsers will wait approximately 300ms from the time that you tap the button to fire the click event. The reason for this is that the browser is waiting to see if you are actually performing a double tap. For most buttons we are developing we know that there is no double click behavior that we want to handle, so waiting this long to start acting on the click is time wasted for users.”

- Ryan Fioravanti

More: https://developers.google.com/mobile/articles/fast_buttons Along with my mobile look, I also have to start to implement mobile behavior. Thanks to Google for the FastButton implementation. It took me just an hour to use it with jQuery and in my own code.

My conclusion?

Developing with Apache Cordova gets you on the road very quickly.

You have something in your hands within minutes. It’s great to progress quickly. It’s not Cordovas fault that the rest of the ecosystem is lacking a few things. There is still no “fantastic” framework which looks on every device as it should look. There is nothing which lets you application “feel” native on every device. Sure, you can deploy to each and any device (almost), but after all: you are not deploying a native app. It’s different.

As soon as you need an App which feels and looks native you have to do some overtime. It’s the details which eat up your budget. Again: it’s not Cordovas fault. Surely JavaScript will perform faster on more modern devices soon. Surely Cordova will stay great. But we now need the other great tools which can be used with Apache Cordova to make HTML5/JS on mobile devices a success.

Sorry to say, jQuery mobile and Sencha and the others are not the answer yet. Apache Cordova is a great tool. As with all tools, you need to look at your requirements and carefully decide if it is for you. If you can accept the mentioned drawbacks and want to come out quickly, it’s great. If you need performance eating animations and want it to be native, go with a native implementation. Don’t believe the hype. Look with your own eyes.

Personally I will stick a bit longer with Apache Cordova. I haven’t got the time to learn objective-c, but I can write JavaScript. As a single-man-show I need every minute. Apache Cordova gives me exactly that. Sure, now I have some CSS work to do. But with the limited functionality I provide in my app, it should not take too long. Feel free to share your experiences, thoughts and helpful links to fantastic frameworks/css libraries in the comment box below.

Tags: #Android #Apache Cordova #CSS #iPhone #JavaScript #jQuery mobile #mobile #phonegap

Newsletter

ABMELDEN