Write Once, Run Anywhere?

03 Oct

by edwardjstone 03.10.12

I recently happened across the very interesting Brackets - an open-source text editor built with HTML, CSS and Javascript in an embedded browser framework. It’s an example of the recurring ‘HTML5 vs native’ debate leading to a hybrid approach - but on the desktop rather than mobile. I wondered if developers were any closer to achieving WORA - without sacrificing performance and usability in the process - or if Write Once, Debug Everywhere (as Java developers are wont to say) was still the unfortunate reality?

Brackets is being developed by Adobe, with the strapline “built with the web for the web”. The About section of the Brackets site focuses on the opportunity for web developers to customise and enhance the application (“if you can code in Brackets you can code on Brackets.”), but I was more intrigued by what this meant for the prospects of massively cross-platform development with a single code-base.

Brackets uses the Chromium Embedded Framework (CEF) to render the HTML, CSS and Javascript UI and business logic, with a thin native wrapper to provide access to lower-level operating system functionality like the file system. This means the application can be compiled to binary distributions for both Windows and OS X (and it would also be possible to do the same for Linux, although the developers of Brackets haven’t done that yet). This is similar to Phonegap, which lets developers write HTML, CSS and Javascript (maybe now is the right time to coin the acronym “HCJ”…) and compile to a native application for a wide variety of mobile platforms. And of course HTML, CSS and Javascript (or HCJ, if you prefer) are already native to the web.

This combination, of CEF with a native wrapper and Phonegap, means that it’s theoretically possible to develop a single application UI in HTML, CSS and Javascript that would run on the web, native desktop and native mobile platforms, only having to change the build process for each. Nirvana!

Of course this isn’t the first time this has been suggested - in the fact it’s not even the first time I’ve thought of it. A couple of years ago, I was discussing with a client using an embedded browser to upgrade a (Windows only) java application. A primary motivation was to avoid rewriting functionality for the web, while another was potential availability (in the browser) on mobile devices. After some investigation, the idea was reluctantly shelved, since the consensus was that CEF at the time was too experimental, and that a web UI wouldn’t be able to replicate the smoothness and speed of a native application in [Java Swing](http://en.wikipedia.org/wiki/Swing_(Java)).

Steve Jobs (in)famously once tried to convince developers that web apps were the way forward for the iPhone but a native Software Development Kit was announced not long after - thought to be in response to jailbreakers and the developer backlash - and the App store and third-party native apps swiftly became a cornerstone of the iOS ecosystem.

Showing that these issues haven’t yet gone away, Facebook recently switched from HTML5 to native for their iOS application, citing performance and user expectations as their primary reasons.

It’s natural for developers to want to use the same codebase across multiple platforms, and for some applications that’s going to work - perhaps for more applications over time as hardware acceleration in the browser becomes better supported and understood by developers. But even in the web browser we’ve not yet achieved consistent support across browsers for all features, and it’s still often the case that to achieve the very best performance and usability native apps are the way forward.

So perhaps what’s more exciting than the dream of WORA is that technology like Phonegap and CEF can make native application development accessible to a whole new group of programmers coming from - and bringing ideas from - a much wider range of disciplines than tradiitional computer science.

Back
blog comments powered by Disqus