Web applications on the iPad

Add comment!

January 28th, 2010

Today, Apple announced the new iPad and humbly claimed that there will be a "gold rush" of native apps for the App Store. Sure, but what I find more interesting is that Apple also ironically created the most promising open web app platform, which may eventually undermine the App Store itself.

Everything shown in the keynote looked great (imagine playing World of Goo on the large touch screen), but what I'm most excited about is the open, WebKit-powered browser: Safari.

The iPad is the first mainstream device which combines all of the following factors: reasonably powerful hardware, a (potentially) huge user base, a mature WebKit implementation, and constant 3G internet capabilities. All the dominoes are in place, and I think that the iPad will knock the first one down.

iPad

A brief history of web apps on the iPhone

Let's go back in time two and a half years to when people were lining up to buy the first iPhone. One of the most contentious topics was Apple's policy that third-party applications would be sandboxed in Safari due to security concerns.

Many people were dubious about this decision, but we were told that it would be fine. The era of web apps was upon us and native third-party apps were unnecessary. Most people scoffed at this, but there were some who agreed with the underlying philosophy that web apps are ultimately the future. This has long been a mantra among web developers, which I actually agree with for the most part, but sadly, even loading digg.com was often enough to freeze Safari on the iPhone.

Web apps gained a terrible reputation and Apple rapidly launched the native app SDK, along with the App Store as we know it today. Soon after, the App Store exploded and became a bona fide gold-rush, and we have not really heard much about web apps since.

What is different now?

However, that was 2.5 years ago. That is an eternity, both in terms of Moore's law and in terms of well-managed, active, open-source projects like WebKit. Keep in mind that WebKit, in addition to having many contributors, is heavily developed by full-time employees of Apple, Google, Nokia, and others -- all with a huge vested interest in its rapid success. Watching new code land in the project is truly humbling.

Here are a few specific examples of improvements to WebKit since the original iPhone was launched:

  • JavaScript and WebKit in general are much, much faster now, due to SquirrelFish Extreme (now called Nitro) and many other optimizations. I am hesitant to put an exact percentage, but I'd guess that WebKit is now an order of magnitude faster than it was when the iPhone was launched. I'm only guessing at exact figures here for the sake of example, but if Webkit is 10 times more efficient than it used to be, and the iPad is 5 times faster than the original iPhone, that means that web apps will run 50 times as fast as they did at the iPhone's launch.

  • Multi-touch DOM extensions have been added to WebKit so that a web app can actually respond to gestures, orientation changes, and other events like you would in Cocoa Touch.

  • WebGL has been added to WebKit so you can use the same OpenGL ES 2.0 API that is available to native apps directly from Safari (n.b. I doubt this has been enabled in the iPad's version of Safari yet, but it almost certainly will be soon!)

  • WebKit has added a quite a number of UI-centric features, for example hardware accelerated transformations, transitions, and animations, which are inspired by Core Animation in Cocoa.

  • WebKit has added support for many modules of HTML5, such as local storage and web sockets, which are critical for desktop quality web applications.

  • Hardware-accelerated video and audio tags are now present and exposed to JavaScript.

It is also important to note that web applications and the web industry have matured as well. Since then, many companies have subscribed to the web app philosophy -- including Google Chrome OS, Palm Web OS, 280 North, the ill-fated CrunchPad, Adobe Air, and many others. I personally believe in it too, having spent the past year working on the UI layer of Overgrowth which is 100% HTML5 (here's an example).

No one has quite succeeded yet. Despite the extraordinary efforts of these other companies and the about-face Apple has made on web apps, I think that Apple is ironically the closest to the holy grail of the native-quality web app platform.

What can native apps still do better?

WebKit has improved dramatically, and I believe that most apps (including virtually all of the non-game apps demoed today during the keynote) could be achieved using HTML5 and other open standards. Maybe a better question is what advantages do native applications still have over web apps?

  • Access to some lower level APIs

While Apple has exposed some, like multi-touch events and orientation, there is some important functionality that remains to be exposed. For example, there is no way to authorize a web-app to access your camera, microphone, photo library, emails, contact list, and other data that a native app could access. HTML5 and WebKit are powerful enough to handle any of this, including a video feed from the camera -- there is no technical reason for this omission.

  • Performance-critical apps.

Despite the dramatic improvements in JavaScript, compiled code is still much, much faster. Keep in mind that this is not really relevant to most apps. It is easy to say "Objective-C is 30x faster than JavaScript! JavaScript is unusable!" but most apps do not need this kind of performance. Basically, if an action takes 100 microseconds in JavaScript, it is not necessary to use compiled code to get it down to 10 microseconds, the difference is imperceptible.

So don't expect to see performance-critical games in Safari anytime soon (although, a game like Flight Control could easily be achieved using WebKit) or an app that requires direct access to say, the microphone (until Apple decides to expose this).

What does this mean for the App Store?

At this point, the question is not really "will native-quality web apps be feasible?" but rather "when will my favorite app be converted into a web app?" or in the case of certain apps "when will WebKit add support for [feature that is not implemented]?" so that the second question is applicable. It is really just a matter of time. If not now, maybe in the next generation of the iPad when WebKit has become even better and hardware has doubled in speed yet again.

Many apps on the app store can already make the transition.

I think that the iPad will soon be joined by quite a few cheaper competitors running Google Chrome OS or an equivalent WebKit powered app layer. WebKit will emerge as the layer in common and as technology and hardware improves, more and more apps will migrate from native code to WebKit so that they can reach more devices. The App Store will have fewer and fewer exclusive titles, and we'll start hearing about success stories from developers who have bypassed the App Store and sold premium, native-quality web apps.

I don't really see Apple going back to just being a premium hardware company now that they are in this position to be the broker and gate-keeper for a closed, super-popular platform, but it will be really interesting to see how they handle the emergence of WebKit.