We're getting close to replacing our old friend "frog"—the current
built the new version with an emphasis on correctness and
compatibility with the Dart VM. This means that you can now take
advantage of some of the niceties of closures and code like this:
var closures = ;
for (var i = 0; i < 8; i++) closures.add(() => i);
for (var closure in closures) print(closure());
01234567 just like on the VM.
The new compiler is available in the latest continuous builds of the
the editor menu, you'll see that we're automatically compiling your
code with both frog and dart2js allowing you to easily compare the
Wrote ...Sunflower.dart.js [103.0kb written in 1.9 seconds]
Wrote ...Sunflower.dart.js_ [126.0kb written in 2.6 seconds]
We're actively working on making the output smaller and faster, so
expect improvements over the next weeks. If you want to try to use the
dart2js output in your web app, you need to change the <script> tag in
the HTML file to include the data-compiler="dart2js" attribute like
<script type="application/dart" src="..." data-compiler="dart2js"></
Writing a new compiler isn't completely trivial, and we're not done yet.
There are a few features remaining before we are at parity with the VM,
such as "support continue in switch statement" and
"support closures in initializer lists".
As always we appreciate any feedback you
might be able to provide us with in the form of bug reports or e-mails
sent to the mailing list (http://www.dartlang.org/
find that your project doesn't work when compiled with dart2js, we
really want to work with you to fix that.
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.
Performance-wise it isn't highly tuned yet, but we feel like we have a
good infrastructure in place for interesting and effective
optimizations. We will keep you posted on our progress!
Kasper on behalf of the dart2js team