Why Facebook won't make the same mistake twice with web apps

How Facebook is betting that its React Native framework will give it the best of web and native app development on iOS and Android devices.
Written by Nick Heath, Contributor

When Facebook chose to build a mobile app using HTML and JavaScript it seemed to be a sign these technologies had matured from tools for creating web pages to crafting software.

The core appeal of such web apps is that any mobile or PC that can run a browser can run your app, bypassing the need to rewrite your software several times using different programming languages native to each computing platform.

But in 2012 Facebook reversed course, following dissatisfaction with the performance of this web app on iPhone and Android handsets. Stung by poor reviews, Facebook wrote separate apps for iPhone and Android devices, using each platform's native language.

Now Facebook is preparing to let a little of the web back into its mobile apps.

Facebook intends to use React Native, its open source software programming framework that allows developers to use the web scripting language JavaScript to build mobile applications that look and feel like their native counterparts.
Facebook's David Mortenson.
Image: Facebook

That native-feel is important if apps are to appeal to users, as it is typically more difficult to get web apps to feel as responsive and to look as visually impressive as native software - as Facebook found out to its cost with its web app.

"We realised the phones were not yet powerful enough and the model wasn't there to have a really first-class awesome experience for both iOS and Android," said David Mortenson, Facebook's director of developer infrastructure.

"I don't think we're going to go back and write a lot of our applications in HTML and JavaScript. I think instead what we're going to do is write them in React Native," he said, adding it would gradually write "more and more" applications using the framework.

On the one hand, React Native aims to give developers the ability to build interfaces using the same components as native applications and to offer similarly sophisticated touch controls. However, on the other, it provides some of the flexibility of the web, such as being able to instantly see changes to the source code reflected in the application.

"It gives us the best of both worlds. It's an environment where you can iterate really, really quickly. You don't have to rebuild the entire application to see your changes, you can just hit refresh in the simulator and you see them immediately. It's an environment that we think is a much more productive one in terms of how you define your view and the things that can go wrong when writing in React Native are much smaller than in Objective C on iOS or in Java on Android."

For Mortenson, React Native will allow Facebook's developers to use many of the same skills when building software across different platforms, offering the benefits of the web without some of its shortcomings.

"We think this is just a strictly better environment. It's also one where it's much easier for engineers to take their expertise and knowledge and apply it on iOS, on Android and on the web. I don't believe in 'Write once, run anywhere'. The model around this is basically 'Learn once, write everywhere'. So we really think that's a better approach for us to take going forward, rather than going back to where we write in HTML and JavaScript."

React Native currently supports iOS and Facebook has said a version that works with Android should be made publicly available in September.

Knocking PHP into shape

While Facebook plans to use React and React Native for its front-end applications, it also continues to advance its own back-end tools - namely Hack - Facebook's reinvention of PHP - and the amusingly-named HipHop Virtual Machine (HHVM) - an interpreter that executes PHP source code.

Hack attempts to correct features in PHP that leave applications prone to errors and make it difficult to use asynchronously, while HHVM gives PHP a shot in the arm, optimising PHP and Hack code so it can be executed far faster.

Mortensen said: "In terms of server-side languages, most of our focus for now internally is figuring out how to make Hack and HHVM an even better language and runtime to serve the backend of mobile development.

"Our traffic is predominantly mobile and is obviously going to be more and more so in the future. If we can figure something out that's really great then I'd expect to also bring that to the open-source community."

Editorial standards