Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

Can Google dart solve JavaScript's speed and scale problems?

Paul Rubens | Sept. 4, 2013
Large JavaScript Web apps can be hard to develop and slow to run. Google's Dart language may offer a solution to address both of those issues

JavaScript is often used in a way that was never intended: as a platform for the development of large Web applications that are hosted in the browser. If that had been its intended use — rather than simply for adding simple dynamism to Web pages — it would almost certainly have been designed differently.

That's because there are two main problems with the language when creating large Web applications.

First, there's the performance problem: There's no getting around the fact that large applications written in JavaScript are relatively slow, and that impacts the end users of the applications.

Second, there's the problem of the structure of JavaScript itself: It's a language that's difficult for large teams to develop in. That's because it lacks structure and strong ties between modules, and because it's hard to communicate the intent of the code within the code itself. For a solo developer that's not necessarily a problem, but for a team of developers working on a large project, communicating the intent of the code is key — especially over time as the original developers move on.

Large applications are usually also modular, and different people are responsible for developing different pieces. But JavaScript is dynamic, and the behavior of objects can change over time. That's very different to what's the case with C or C++, or even Java or C#, and it means you generally need to execute your code to verify that it works.

The Need for Web App Speed
JavaScript has certainly enjoyed some considerable speed improvements over time, and there was a great leap forward following the introduction of Google's V8 JavaScript engine about five years ago. But it's apparent that JavaScript developers are hitting the speed limits with the current generation of JavaScript engines. To make the next great leap forward in performance a new approach seems to be called for.

One possibility is asm.js, a highly restricted subset of JavaScript that doesn't have the dynamic characteristics of JavaScript that make it hard to optimize.

As the name suggests, this is intended to be thought of as a kind of assembly language for JavaScript engines. It's currently in beta, and it's being pushed forward by Mozilla.

As it is a subset of JavaScript it is fully backwards compatible with current JavaScript engines, and in an engine that is asm.js ready it runs faster than normal JavaScript, at up to about half the speed of native code.(The latest version of Firefox [Version 22] has support for asm.js optimization, and there's a demo of the technology on the Mozilla Developer Networks site.)

Just as C++ or C# developers may drop to a lower level language when they want to tackle a particularly performance-critical piece of code, asm.js could be used by JavaScript developers — most likely games developers — when they come to the most performance critical parts of the code. It's not something you would want to develop a whole application in, but it will allow a subset of the code to run very quickly.

 

1  2  3  Next Page 

Sign up for CIO Asia eNewsletters.