· 12 min read Posted by Touchlab

HTML5 Taking over the app world

I think you might read that title and think this is going to be about how HTML5 is steadily taking over the native app world on mobile devices.  I think we hear a lot about this because thats the story people want to hear, so it gets amplified quite a bit.

The truth of the story can be summarized by slightly changing the statement.  HTML5 COULD BE taking over the app world, but the people that matter don’t want it to.

I apologize in advance.  This is more of a brain dump than a “blog post”.  I will need to go back and edit quite a bit, but we’ve got actual work to do today, dammit!  Anyway…

My theory is that neither Apple nor Google want you to write apps in HTML5, but if they did, you could.  And it would be awesome.  Because they don’t, its very difficult to pull off elegantly.

You could say, “but Google TOTALLY supports HTML5?!”.  Yeah, but not in the app ecosystem.  Its true that Goog and Apple work hard to make the web experience fairly smooth on mobile devices, but not as an app platform.  You can use WebView to host content, and I’m not sure we’ve done a significant app that didn’t use WebView in some way, but as a full app platform, ideal it isn’t.

I can say this kind of stuff all day, but I run an Android dev shop, so I’m partial.  Maybe I don’t want HTML5 apps, right?  In a former life I did piles of Javascript and Ajax.  I actually built a trading screen in Javascript and Ajax.  I was really excited about WebOS, and thought PhoneGap was brilliant and would eventually be a major app platform.  I no longer think those things.

The Evidence.  I will present my evidence in a few broad categories: desktop parallel examples, current phone HTML5 implementations, and current cross platform implementations, then discuss some of the misconceptions around cross platform development in general.

1) Cross Platform In The Desktop

There are a number of projects that have attempted over the years to produce an XP solution for the desktop.  While some have had greater or lesser success, nothing has really been successful.  Most desktop apps are built in their native environments.    Most functionality has, of course, moved to the web, but if you build a desktop app, its native.  This is not because of lack of effort or smarts.  Its because the people that sell these desktop OS’s have no interest in XP solutions.

Java

There was a time when Java was going to take over the desktop.  You could “write once, run anywhere”.  While version 1 was kind of a joke for this idea, later versions should have made that a reasonable possibility.  While you could argue that Swing’s lackluster performance killed it, Microsoft’s concerted effort to prevent Java from gaining any traction was really punch in the gut.  They copied it, crippled it, and did all manner of nasty things to make Java a maintenance nightmare.  Most apps actually did a good job of running in different environments, and many internal apps were built on it, but right now I can only think of 1 or 2 public apps that are built on Java.

Question: How do we think this would have worked out if Microsoft had cooperated with Sun and helped Java rather than strangling it?  Maybe it still would’ve been crap (Sun strangled JavaFX all by itself), but maybe things would’ve been different.

There is only XUL

A few years back, Mozilla released something that sounded like the perfect answer.  XUL.  Its a framework that lets you build feature rich desktop applications using an XML definition language, with CSS, Javascript, etc.  Its free, and uses technologies developed for the web.  It should work cross platform without much trouble.  In fact, I’ve seen a few awesome apps using it.  The Songbird desktop client used to (not sure if it still does).  Since it uses basic web technologies, provides a rich set of components, and performs well, you’d think it would be all over the place.  Its not. In fact, it seems like kind of an afterthought at this point.

For better or worse, fair or not, I would be FAR more Mac and Windows apps are built in either native Mac or native Windows development environments than anything approaching “cross platform”.  This wasn’t a huge deal when Apple was still on the ropes as a company, but now that Macs are all over the place, the need for a cross platform solution would seem even greater.  Machines perform better than ever, so the slightly lower performance of the cross platform solutions would seem like a minor issue.  Plus, we’ve had about 15-20 years to come up with something that works well.  Still waiting.

You could argue that the web is the cross platform solution for the desktop, and your argument would be pretty persuasive.  I’m not arguing that things better suited to being web apps aren’t going to stay that way.  I am arguing that for things that want to be locally installed may not be written in HTML5, as many seem to be predicting.  The major issue with everything moving to the web for phones is how they’re used, and spotty connections.  First time app developers tend to view phone development like they have an always-on connection.  You really need to think of your phone like its connection is almost always off.  If you don’t design that way, there’s a really good chance your app is going to perform badly.

So, anyway.  History would suggest we could be waiting for a long time before a cross platform solution presents itself, assuming the major players don’t want it.  And I’m pretty sure they don’t.  Know why I’m pretty sure?  More evidence.

2) Current Mobile HTML5 Implementations

HTML5 as a mobile device development platform is not rocket science.  It is VERY possible, and has been done.  If Google and Apple wanted HTML5 as a first class citizen, they could have it.

WebOS

Read the excellent article on the verge about WebOS.  Palm was on the ropes, and they pulled a (relatively) last minute move basing their entire stack on HTML5 and Webkit.  And it worked.  Not only did WebOS work, but pretty much everybody was blown away.  I think we all had that “the future is now” moment, looking forward to moving our HTML/Javascript skills to a new platform, and before long, HTML5 would be the app platform of choice.  The failure of WebOS was not the result of their platform choice.  The point here is that it absolutely can be done, but those in charge need to want it.

Firefox OS (aka Boot to Gecko)

Basically the same point as WebOS.  A company operating on a relative shoestring is building a smartphone platform based on HTML5, and it seems like they have some interested partners.  At first I thought they were insane, but they’re going after low end phones.  LOW END PHONES!?!?!  Again, HTML5 as a core app development language should not be hard.  Its TOTALLY possible, but only if the people holding the keys want it in there.  I find this move particularly interesting, as the “low end smartphone” space is dominated by Android.  I would guess the average phone user is far more concerned that their phone works and they can play music than of the OS particulars.  If Firefox can do a solid job with mail and contact integration, they might be able to pull off something interesting here (and if Google can put their ads and maps in there, I’m not too sure they’d be upset).

HTML5 based apps aren’t some super problem just waiting on somebody to come along and figure them out.  Both platforms above were built by teams under huge time and resource pressure.  It can be done.  In fact, I’m pretty sure we could just copy WebOS, right?  It is open source.

3) Current Cross Platform Implementations

There are multiple XP implementations out there, but the only two I find interesting are PhoneGap (now Cordova, which I’m refusing to accept) and Appcelerator.  Both work.  I’m not sure either works well.

PhoneGap

I had a serious crush on PhoneGap.  What a fantastic solution.  Write your little app, tweak it a bit for different platforms if needed, then you deploy anywhere.  Awesome!  I never really sat down to write anything for it, but recently we took on a project porting a PhoneGap app written for iOS to Android.  PhoneGap, I’ve had some time to get to know you.  My crush is gone.  Very, very gone.  You have lots of baggage, you won’t communicate when something is wrong (IE shitty debugging support).  I’ll expand on the details a bit later, but its been mostly a disaster.  This is not entirely PhoneGap’s fault (although you need to add a source jar to your distribution, and until you do, you fail hard), but not being their fault doesn’t change reality.  Our project was pretty painful, and as mentioned, I have a black belt in Javascript and HTML.  It was an eye opener, and knocked PG from the top of the “if you MUST try cross platform, look at …” list.

Appcelerator

I have a love/hate thing with Appcelerator.  When I first tried it, I was using Linux, and although it was supposed to install on Linux, it didn’t.  Android was sort of the red-headed stepchild of Appcelerator.  The basic pitch was, build your iPhone app, and you can release an Android app too (maybe).  Since then, Android has become the dominant platform, and although many people simply choose to ignore that, I’m pretty sure Appcelerator has improved Android support quite a bit.  I also used to hate the proprietary nature of the platform, and although its certainly not a “standard”, they’re open source now, so I can’t get all that upset about it.  I expect a good number of internal corporate apps to be built this way.  you can sacrifice a little “pretty” for functional.  Same thing that drove the endless Visual Basic and Java Swing that scar our corporate intranet landscape.  As a platform for consumer facing apps, I’m less convinced that Appcelerator will be huge.  I’m sure there will be plenty of it out there, but I’d be shocked if it suddenly swung the needle the other way.

I don’t really “like” it, but in terms of what I would use if I had to, at this point I think it would be Appcelerator.  You control native components with Javascript.  That sounds like a reasonable approach.  I’m not sure I’d bet my company on it if the app was remotely complex, or if you really needed to worry about design details, but I’m basing that off of no research.  YMMV.  Because Appcelerator straddles iOS and Android, the components need to be of the lowest common denominator variety (Button? yes. ViewPager? probably not).  I’d also be VERY concerned about not having an escape hatch.  At least with PhoneGap, I’m pretty sure you could dump out to native if absolutely necessary.  Not sure about Appcelerator.

Also, again I haven’t used it, but I would bet the apps are modeled much closer to iOS than Android.  As such, it would be Back Button Bingo.

XP Misconceptions

One of the biggest assumptions when talking about cross platform apps is, if you can get it to work, you get 2 for the price of 1.  We’ll ignore Windows Phone for now.  Although PhoneGap technically supports it, I wouldn’t even try doing an XP app on WP right now.  Anyway, the problem, of course, is that writing a cross platform app takes longer than writing a single native one, assuming you have comparable experience on your platform of choice.  So, the “1” in “2 for 1” isn’t actually “1”.  Its more.  How much?  Depends.  I can’t really say, but its significant, and will vary based on complexity of the app.

The other problem is, you don’t really get “2”.  While you could convince me that you’ve written a passable XP app that works on iOS and Android, I will eat my hat if you show me an XP app that’s as good ON BOTH PLATFORMS as it would have been if written in native on each (disclaimer: I have no hat).  The “2” isn’t really “2”, if you value design and UX at all.  Maybe your demand is fixed, so unless your app simply doesn’t work, you’ll have the same user base.  Then, of course, that “2” is pretty much “2” regardless.  However, if like pretty much every consumer product, design and UX matter, you need to subtract some because your app isn’t going to be as clean, fast, etc.  Its just not.

Developing on a native platform, assuming aptitude, is easier than any of the XP solutions.  There is better developer support, you’re closer to the “metal” so to speak, and there are significantly better debugging and error tracking tools.  I still don’t know how to attach a debugger to the WebView/Javascript in PhoneGap.  WTF?  The other piece of the puzzle is the second platform you develop for is WAY easier than the first.  We’re an Android shop, so almost everything we do is develop for the second platform.  Trust me.  Way, way easier.  Assuming you don’t do something crazy like do both at the same time.  You’re not going to do that, are you?

I seriously need to reorg and edit this, but you get the idea.  You can write your app in HTML5, but it won’t be pleasant.  And as far as HTML5 taking over the app world, don’t hold your breath.