How does the dart javascript compiler (dart2js) work?

compiler-construction, dart

Solution

The Dart Editor will now compile your Dart code to JavaScript with dart2js.

As for the second part of your question, the dart:io libraries are only for the server/command-line, so they can't be compiled with dart2js.

I realize now I think you are asking "how did the engineers design and implement the dart2js compiler", not "how do you run dart2js"

Here's a blog post on the announcement of dart2js: http://news.dartlang.org/2012/05/new-dart-to-javascript-compiler-ready.html

Kasper Lund, one of the engineers, adds "For the technically interested, I can tell you that the new compiler uses an internal representation in SSA form (static single assignment) and that the compiler is implemented entirely in Dart."

The source code is at http://code.google.com/p/dart/source/browse/#svn%2Fbranches%2Fbleeding_edge%2Fdart%2Flib%2Fcompiler%2Fimplementation

Problem

Dart runs in its own Dart VM, but you can compile it to modern optimized JavaScript. But how does that work? Are there any articles or papers online which explain that process? I am wondering if that is an easy straight forward matching element to element, only time consuming to develop, process or are there some elements/aspects of Dart which could not be compiled to JavaScript. http://www.dartlang.org EDIT:thx for your 2 answers. The point is, that i told a collegue of mine about dart and that dart can be compiled to JavaScript. He accepted that it could be compiled to JavaScript but it would result in mumbojumba code and will only work for simple stuff. In the end he said: '''ok, explain me. how is this compiling going to work on nontrivial code?''' That's why i am asking. I was hoping that there is some material online i could link him.

Original source