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.
Contents. Version note: Dart 2.18 removes the dart2js command-line tool from the Dart package, but retains the dart2js compiler. Use dart compile js to compile Dart code to deployable JavaScript.
The dart code both SDK's and ours are compiled through AOT (Ahead-of-Time) compilation process to native ARM libraries. After successful compilation, the IPA (iOS extension same as APK) file is generated. Any widget rendering, input-output, event handling and so on is done by compiled app code.
The Dart development compiler (dartdevc) compiles Dart as JavaScript AMD modules. These modules work for web app development in modern browsers. Note: Dart 2.18 removes the dartdevc command-line tool from the Dart package, but retains the dartdevc compiler. Use webdev serve to compile Dart code to modular JavaScript.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With