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.
InfoQ Homepage News Languages Come to Javascript VMs: CoffeeScript 1.0, StratifiedJS, C/C++ with Emscripten, Python
Languages Come to Javascript VMs: CoffeeScript 1.0, StratifiedJS, C/C++ with Emscripten, Python
This item in japanese
Community comments
http://haxe.org/
by Vic _,
Re: http://haxe.org/
by Werner Schuster,
Re: http://haxe.org/
by Rusco Rayban,
Significant white space !#@!
by jean-simon Larochelle,
I don't know anyone who really tried Python for more than a day...
by Luciano Ramalho,
Re: Significant white space !#@!
by Dave Nicolette,
Scheme in JavaScript
by Hara Yutaka,
http://haxe.org/
by Vic _,
Your message is awaiting moderation. Thank you for participating in the discussion.
And the most popular.... not on the list.
Significant white space !#@!
by jean-simon Larochelle,
Your message is awaiting moderation. Thank you for participating in the discussion.
I was told that significant white space was not a problem with Python. The first time I tried python I had trouble running my script. The indentation looked ok and the code as well nevertheless I was only able to run my script after complete rewrite that looked exactly the same. The problem was whitespace but I was never able to understand what was the problem by looking at the code. Maybe using an Hex editor.
This and other experiences confirm my feeling that significant white space are not a good idea.
Re: http://haxe.org/
by Werner Schuster,
Your message is awaiting moderation. Thank you for participating in the discussion.
Yes, this newsitem is concerned with languages and runtimes that have been released in the past few months.
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,
Your message is awaiting moderation. Thank you for participating in the discussion.
and still thought significant whitespace is a real problem. Once you spend a few minutes properly configuring your editor or finding a suitable one, the issues go away and what remains is a clean, readable block syntax that is being adopted by more and more languages. But if you just want to dismiss Python, there are easier arguments: it is named after a comedy troupe, so how can it be serious?
Scheme in JavaScript
by Hara Yutaka,
Your message is awaiting moderation. Thank you for participating in the discussion.
One more for the list:
biwascheme.org/
Re: http://haxe.org/
by Rusco Rayban,
Your message is awaiting moderation. Thank you for participating in the discussion.
It's a pity that the haxe guys are so focussed on the the flash runtime, not to mention php and c++ (ugh....) The haxe technology could really be a serious GWT competitor if they only would recognize the strategic value of Javascript.
Re: Significant white space !#@!
by Dave Nicolette,
Your message is awaiting moderation. Thank you for participating in the discussion.
Maybe it was a question of tabs vs. spaces.
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.