Three technologies that want to improve on JavaScript

The hunt is on for a technology to overcome the performance limitations of the technologies originally designed to serve static web pages.
Written by Nick Heath, Contributor

World Wide Web creator Tim Berners Lee may dream of people running apps in web browsers that rival those running directly on computers, but myriad obstacles remain.

For web sites and apps, JavaScript is the defacto client-side scripting language used to add the dynamic content that turns a static page into an app or a game.

But JavaScript's performance is hobbled by both its architecture, its dynamic nature, and how it is run, as an interpreted language.

The performance of JavaScript has come on leaps and bounds in recent years, thanks to browser JavaScript engines using just-in-time compilers, which typically compile certain stretches of JavaScript into machine code just ahead of being run.

But as people turn to the browser to realise more demanding tasks, such as photo editing and gaming, the hunt is on for a better performing alternative to deliver dynamic content in the browser.

A number of new technologies and approaches, from asm.js to Google's Native Client, are being touted as a possible alternative to vanilla JavaScript. Each is designed to help the performance of code running in the browser get closer to that of native code: compiled machine code that is executed directly by a computer's CPU.

However with major companies like Google and The Mozilla Foundation backing different technologies for Chrome and Firefox browser - it remains unclear which of these, if any, will likely win out.


The Mozilla Foundation has thrown its weight behind asm.js, a subset of JavaScript capable of delivering performance near to that of native code.

Mozilla has demonstrated asm.js carrying out a number of computationally demanding tasks, such as running a modern 3D graphics engine in this demo of Unreal Engine 3 and handling complex physics calculations needed to simulate hundreds of falling boxes.

Asm.js is a subset of JavaScript that eschews several dynamic features of the language and in doing so allows JavaScript engines in the browser to make performance optimisations that JavaScript's dynamic nature would render impossible, and help it to deliver just over 85 percent the performance of native code in a Whetstone benchmark.

Developers don't write code in asm.js, but rather typically write in C or C++, and use the Emscripten compiler, another Mozilla project, to output asm.js.

However, support for asm.js is limited to Firefox for the time being, although Google has expressed interest in adding support for asm.js optimisations to Chrome, and there are other performance limitations asm.js doesn't address, such as JavaScript engines not really being able to handle multi-threaded code.

Native Client

Google's Native Client (NaCl) allows web browsers to execute compiled C and C++ code within a sandbox.

Google is aiming for the performance of apps running inside NaCl to be superior to that of asm.js, coming within a few percentage points of native code.

As well as the performance benefits NaCl brings over JavaScript, it allows developers to reuse existing C and C++ code libraries.

Google has used the technology to power its recently launched photo editing tools for Google+, based on the Snapseed photo app technology it acquired from Nik Software.

NaCl runs inside the Chrome browser on Windows, Mac, Linux, as well as on Chrome OS.

However, despite NaCl being publicly demoed in 2011, other browser vendors are not currently supporting the open source project, and prominent members of The Mozilla Foundation have distanced themselves from the notion of running native code inside a sandbox.

Google Dart

Google's goal with Dart is to "replace JavaScript as the lingua franca of web development".

Dart is a scripting language designed to address a range of shortcomings of JavaScript, with Google claiming it is both easier to program in and offers superior performance.

Dart outpaces JavaScript on two significant benchmarks – Richards and DeltaBlue, according to Google tests. Google has also demonstrated how Dart's support for SIMD (Single Instruction, Multiple Data) instructions, which allows the same operation to be carried out on multiple data points simultaneously, can deliver three times the frame rate of an animation rendered without it.

Google's Dart benchmark. Image: Google

Dart – a class-based, single inheritance, object-orientated language with C-style syntax – is at a disadvantage in that supporting it would require browser makers to add support for another runtime – while every major browser supports JavaScript.

Neither Mozilla or Microsoft have shown any interest in implementing support for the scripting language directly and the only browser to run Dart directly is a special version of Chromium that embeds the Dart Virtual Machine.

Dart can also be compiled into JavaScript using the dart2js compiler, although JavaScript compiled from Dart won't run as fast as native Dart.

Speaking earlier this year Google programmer Lars Bak said Google's ultimate aim is to get Dart into Google Chrome.

JavaScript evolution?

Apart from these options, there is also the chance that the performance of JavaScript and other web technologies, bolstered by the growing power of the computers they run on, may reach a point where it is good enough for 90 per cent of apps out there, a view recently put forward by Jo Rabin of the web standards body W3C.

Further reading about web development

Editorial standards