Languages Come to Javascript VMs: CoffeeScript 1.0, StratifiedJS, C/C++ with Emscripten, Python
Javascript VMs are now ubiquitous and increasingly fast - two attributes language designers and implementers like. Languages that target the JVM or.NET have seen a lot of interest, but recently a lot of new languages and language runtimes target Javascript.
A pain point of Javascript is the language itself, so developers are creating new languages that compile to Javascript.
CoffeeScript, which has just released version 1.0, is a new language that aims to clean up Javascript and add a few useful features. The CoffeeScript compiler is written in CoffeeScript and compiles to clean and pretty printed Javascript.
Significant whitespace is used instead of braces to delimit blocks - a fact that will keep discussion forums buzzing, although it is in line with other recent languages like CSS3 extension Sass, Haml, etc.
CoffeeScript has been around for about a year, and has recently gained exposure through a few public projects that used it. ArsTechnica's iPad application is written using HTML and CoffeeScript and runs as native application using PhoneGap. 37Signal has published Chalk, a whiteboard app that runs on the iPad and uses HTML5 features, such as the Cache Manifest, to run offline. It also uses CoffeeScript.
StratifiedJS is a superset of Javascript that adds a few concurrency related keywords to adress the verbosity of async programming. For more details see the interview which describes the motivation behind StratifiedJS and the browser implementation Apollo.
The Emscripten project uses a different approach. Emscripten tries to bring languages with LLVM compilers to Javascript VMs. LLVM can compile code to bitcode which Emscripten then and translates to Javascript. Manual memory allocation is supported to a degree; Emscripten emulates it with a heap array that's managed by a custom version of malloc.
C and C++ code can be translated using Emscripten and the project's site has a few demos of translated C and C++ libraries. However, it also has demos of translated versions of Python and Lua runtimes.
Next to these new languages and translated runtimes, existing languages also get ported to Javascript, such as Haskell, Steve Dekorte's Io language as well as Python again with the Skulpt project.
It remains to be seen which of these approaches will prove successful and useful. One thing is certain, though: Javascript VM, JIT and GC developers had better keep the performance improvements coming if approaches like Emscripten become popular.
Significant white space !#@!
by
jean-simon Larochelle
This and other experiences confirm my feeling that significant white space are not a good idea.
Re: http://haxe.org/
by
Werner Schuster
For a longer list of languages for Javascript VMs see:
www.is-research.de/info/vmlanguages/category/ja...
I don't know anyone who really tried Python for more than a day...
by
Luciano Ramalho
Re: http://haxe.org/
by
Rusco Rayban
Re: Significant white space !#@!
by
Dave Nicolette
I think there are some advantages to using indentation to denote blocks.
(1) There is no way to munge the code to minimize whitespace. This was a technique meant to reduce data transfer overhead in the days when transfer speeds were problematic. Today, code readability trumps transfer speed optimization (at that level of optimization, anyway). Obsessing over whitespace is now an anachronism.
(2) Also related to code readability: The ending delimiters for code blocks are just visual clutter. It's easier to see what's going on in the code when blocks are clearly called out by indentation.
Just one opinion, of course.
Educational Content
Tuning the Size of Your Thread Pool
Kirk Pepperdine May 23, 2013
Co-making Great Products
Jeff Patton May 22, 2013




Hello stranger!
You need to Register an InfoQ account or Login to post comments. But there's so much more behind being registered.Get the most out of the InfoQ experience.
Tell us what you think