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

In fact most developers will probably never use asm.js directly at all. More likely they would use C or C++ (or take existing C or C++ applications) and then compile the code into asm.js using the Emscripten transcompiler.

Large Scale Web App Development
It might provide a speed advantage, but when it comes to developing large scale Web applications in JavaScript, asm.js doesn't help. What may help, though, is an open source Microsoft initiative called TypeScript. Conceptually TypeScript is the exact opposite of asm.js: where asm.js is a subset of JavaScript, TypeScript is a superset.

What this superset does is bring some structure to JavaScript development, providing a command line compiler that emits regular JavaScript, type checking, and Visual Studio 2012 integration via a plugin. What it doesn't do is provide a performance advantage: TypeScript compiles to JavaScript that runs at a similar speed to handwritten JavaScript.

Web App Speed and Scale
So asm.js promises greater speed, and Typescript provides a JavaScript development environment that's suitable for large scale Web applications. But neither approach offers both.

That's where Google's Dart comes in. The goal of Dart is "ultimately to replace JavaScript as the lingua franca of Web development on the open Web platform," according to a Google internal email.

It's an ambitious goal, so what is Dart? It's an open source programming language that's been designed with the application of large scale applications and high performance in mind. In fact calling Dart a language may be a misnomer, because a validator and various other development tools are all bundled in Dart.

Applications written in Dart can run in a Dart virtual machine (VM) at about twice the speed of JavaScript on browsers that support it. At the moment there's only support for Dart in a custom version of Google's open source Chromium browser called Dartium, but support will almost certainly be added to Chrome as well.

Compiles to JavaScript
It can also be compiled into JavaScript for general browser compatibility using the dart2js compiler. While JavaScript derived from Dart won't run as fast as native Dart, it will run faster than handwritten JavaScript, according to Chris Buckett, a software developer and author of "Dart In Action."

"When code is converted from Dart to JavaScript the compiler does 'tree shaking'," Bucket says. In JavaScript you have to add an entire library even if you only need it for one function, but thanks to tree shaking the Dart-derived JavaScript only includes the individual functions that you need from a library, he says. Dart also analyzes your code and can optionally do a form of type checking, and can remove some manual checks that aren't necessary, Buckett says. With handwritten JavaScript, developers are forced to program very defensively, he adds.


Previous Page  1  2  3  Next Page 

Sign up for CIO Asia eNewsletters.