An emerging trend: Compiling to Javascript

posted in: Uncategorized | 0

Over the past few years, Google’s V8 and Mozilla’s Spidermonkey Javascript runtimes have greatly improved the performance of web browser Javascript. Now that Javascript is no longer a toy but a serious platform, software developers are using Javascript to build web applications. For example, Node.js is using Google’s V8 Java runtime as a server-side website application platform.

My previous blog posts have enumerated several technologies built on Javascript to aid software developers in building web applications faster, including Angular and Ember MVVCs and jQuery/D3 DOM manipulation libraries. In this post, I want to introduce a new set of developers tools to help produce Javascript code.

An emerging trend in the industry is to compile code from another language to Javascript. New scripting languages such as Coffeescript and DART are translated to Javascript. The benefit of using these new scripting languages is to overcome perceived limitations in Javascript syntax. Coffeescript makes it easier to write Javascript by reducing overly verbose syntax in Javascript, especially asynchronous callbacks and lambda expressions. Google introduced the DART programming language with strongly typed variables, which helps to catch bugs during compilation instead of at runtime.

A second exciting approach is to compile existing codebases to Javascript. One such tool is Emscripten, which compiles C and C++ to Javascript. C and C++ are the industry standard for code bases since the 1980s. By moving C and C++ to the web, large code bases are reused and development efforts are greatly reduced. For example, classic games originally written for MS-DOS such as Doom are now runnable in a web browser. Modern games such as Unreal Epic Citadel can be ported to Javascript. Software developers can take also take advantage of C and C++ language features, such as strongly typed variables and compile-type syntax checks, to reduce bugs before runtime.

This second approach to producing Javascript code is a definite game changer. Existing applications can be ported to the web browser for mass distribution. Javascript runs in a security sandbox instead of having to download native-code binaries, which improves protection for the end user. Web-based applications can be republished quickly when the URL is reloaded, instead of relying on end users to upgrade software. New tools such as Emscripten are making this transition feasible for software developers.