HTML5 mobile app or native? It depends

Get 40-Page ReportNOW AVAILABLE: State of Performance Engineering 2015-16

When tasked with developing an app, is it better to write an HTML5 mobile app or to go with native code instead? The question has become a debate that swings like a pendulum. Instead of choosing a side, many developers are finding that they should use whatever works best for the task at hand—be it HTML5, native code, or a hybrid approach.

The HTML5 mobile app dream

HTML5 was supposed to solve all sorts of compatibility and speed problems. Apple originally pushed iPhone developers into HTML5 web apps. In 2010, Facebook famously decided to build everything in HTML5 and then reversed course just two years later. "[P]eople expect a fast, reliable experience and our iOS app was falling short," said Facebook engineer Jonathan Dann.

Back then, HTML5 was slower than native code, couldn't access device functions, and didn't have an immersive feel. Today, while there has been a lot of progress in HTML5, there's still no one-code-fits-all solution.

HTML5 pros and cons

HTML5 mobile apps have clear advantages. They can be cheaper and easier to create because so many people know JavaScript. And since JavaScript runs on any browser, an HTML5 app will run on any mobile device (at least in theory).

Speed has also improved. "The JavaScript engines have been getting better and better," according to Dr. Andy Piper, CTO of Java-based middleware company Push Technology. "We certainly have demonstrator apps that are as fast on JavaScript as on native apps...It's difficult to quantify how much over the bar it is in terms of the requirement, but it definitely is over the bar."

Smartphones and networks are also much faster. GeekBench shows that the latest iPhone is ten times faster than a 2009-era 3GS, for example.

In addition, there's a growing choice among third-party software that extends the capabilities of HTML5 to better match native apps—even providing access to some device features.

However, HTML5 is risky. "To get anything done you need to use a lot of these third-party systems," Piper said. "But it's a Wild West. It's somewhat amorphous in how it's changing and how it's controlled." Third-party vendors may not have the discipline and predictability developers expect from larger corporations. A hasty release or an injudicious change in the API and an app can suddenly break.

Third-party software also has to be downloaded when an app is started. That takes bandwidth and time. If there's a poor connection, the process can take longer or even be disrupted. And even the cross-platform capability can be a challenge because of different platform conventions. A simple example is how iOS users swipe up to gain access to certain system features, but Android users swipe down. If you incorporate a swipe down gesture in the interface, you might frustrate Android customers who accidentally open the system features.

Native basics

Unlike an HTML5 mobile app, a native app is compiled, typically leading to better performance. But more important is what developers can achieve with native code, whether on iOS or Android.

"There was a big push a few years ago for HTML5 and a lot of big apps were written in it," says Aaron Glazer, CEO of mobile app testing company Taplytics. "But since they went native, there has been a big deliver these very rich experiences...that are very difficult to replicate on HTML5."

"When the app is native, you have the ability to take advantage of all the different built-in elements of the underlying platform," Glazer explains. "Users have become so accustomed to these rich experiences that even a minute change to HTML5 becomes noticeable...and leads to users not enjoying it as much and not using it as much."

If you need to use the accelerometer or GPS, HTML5 may not give you enough control. Additionally, there are features you might not be able to code in JavaScript. Greg Sterndale, a software engineer and cofounder of PromptWorks, points to Yelp's Monocle as an example. This augmented reality feature overlays reviews on a live feed from the rear camera. "JavaScript would have a hard time overlaying the information that you want on top of the video," he says.

Another challenge for HTML5 is storing data when a device moves in and out of wireless reception. "Doing so in the browser is cumbersome. We had a client with an application like that," says Sterndale.

But a native app isn't without shortcomings. If you need cross-platform support on Android and iOS, you're likely looking at two different development teams. That alone significantly increases the cost.

HTML5 vs. native—or both?

In general, if you need to provide an immersive experience, convince consumers to adopt your app, or have a feature that would be tricky in HTML5, native is likely the way to go.

However, there are situations where a web app is better. "The main reason for that is when [a company] has a limited budget or when it does not need to use onboard device sensors such as accelerometer, GPS, and so on," says Yaroslav Vorontsov, a senior software engineer from DataArt. You might need an app on multiple platforms while working against a pressing deadline, or perhaps the audience is an internal one and making data or some capability available quickly is more important than the interface.

No matter which approach you choose, keep an eye on HTML5 developments. Over time, its benefits, in conjunction with advances in third-party software, might make you reconsider how to write that next app.

Get 40-Page ReportNOW AVAILABLE: State of Performance Engineering 2015-16
Topics: Mobile