Monday, June 18, 2012

HTML5, Flex or Native?


We are in a world which is moving at a very rapid pace and it's important that we move along.

The world is going mobile and most of the companies want to extend their offerings to mobile platform. For any developer or organization, the first question that comes to mind is which technology to adopt. When I started, I had heard of three HTML5, Flash and Native (Java for Android and Objective C for iOS), of course there are others like Corona and Titanium.

When I started, I also faced this difficult choice. However, the decision was made easier by the fact that Flash / Flex was not supported on iOS and I had not worked on Objective C at all so HTML5 was the easier way out, more so, considering the fact that our product was going to be a cross platform app.

HTML5
HTML5 is cool and it's easy to develop things once you get the hang of it. With amazing libraries like Backbone JS, Sencha, Jquery and others, it's fun to develop with HTML5. For the APIs like Camera, FileSystem etc. that HTML doesn't have direct access to, PhoneGap comes to rescue. The most commonly used APIs are provided by PhoneGap and it also provides the ability to write your own plugins to extend the reach of your app. The best part of using a cross platform technology like HTML is that your core application code needs to be written just once and it's only the plugins that need to separately developed for each supported platform. So, overall the combination of HTML5 and PhoneGap is amazing. This is the reason that a lot of companies are adopting HTML5 as their preferred technology.

However, there are some limitations too. As HTML5 is dependent on the browser component, the behavior is not always consistent across devices. The issue is more prominent on Android as each device manufacturer comes up with their own browser which interprets things differently. Such issues make developer's life miserable as it is impossible to always depict the correct behavior.

Flash
Coming to the other cross platform technology i.e. Adobe Flash. Despite all the predictions of Flash being on verge of death and the PR blunder by Adobe, Flash is still going strong. It is still the most preferred platform for games development. Like HTML5 Flash is also a cross platform tool that allows you to code once and deploy it to multiple platforms. One major advantage Flash enjoys over HTML5 is that it is not dependent on the browsers so the behavior is generally unique across devices. Like PhoneGap plugins, Flash has a concept of ANE. AIR Runtime Extensions allow the developers to write native plugins to expand their app's reach. Stage3D and StageVideo enable developers to improve the performance by getting rid of the display list. Another great advantage of using Flash is that you can make use of the huge amount of eLearning assets made in Flash over the years.
As with HTML5, there are certain limitations with Flash too:
  1. AIR run time gets included with all the mobile apps which adds up around 2 MB. If you use Flex SDK, add 3-4 MB more
  2. Build process for iOS is slow and it's very painstaking to debug iOS apps built with AIR
  3. For any issues or bugs in the AIR run time, one needs to wait for the new releases by Adobe.
Flex has been donated to Apache by Adobe and they are pretty close to rolling the first version of Apache Flex out. I see a lot of promise here. So, despite what people say, Flash is still live and kicking.

Native Development
By native development, I mean Java for Android and Objective C for iOS.Developing in native language would assure you of one thing for sure and that's that the performance of your would be much better when compared the cross platform technologies, be in HTML5 or Flex.

When developing native, you would invariably be forced to follow the workflow designed for the particular platform. This is one aspect, which generally gets ignored when developing cross platform and hampers the user experience. An iPhone user is used to seeing the apps behave in a way and Android users in other so it's important to take care of these while development. Native development helps in faster development too. As all the APIs are available for disposal, there is no need to write extensions to be able to use them and this saves a lot of development effort. The only shortcoming with developing native is that you'd need to learn multiple technologies and each app would need to be rewritten for all the platforms it supports.

So, at the end of it all, do we have a clear answer on which technology to use? No, I believe that it's horses for courses. Carefully analyze the job in hand and then decide on the technology. Love the times we are in, so many tools available to do the job, pick and choose any one.