3 ms·
Dart can optionally compile to Javascript, so a program written in Dart will run in all browsers, albeit with a fair bit of overhead from the translation (exact
by spankalee 15y ago
Dart can optionally compile to Javascript, so a program written in Dart will run in all browsers, albeit with a fair bit of overhead from the translation (exactly how much overhead remains to be seen, but Dart code compiled to Javascript will certainly be suboptimal, or else Google wouldn't bother implementing a virtual machine solely for Dart).
The overhead of Dart compiled to Javascript will hopefully be very minimal, and in some cases Dart might generated code that runs faster than what a programmer might write.
The reason for the existence Dart VM is not because Dart->JS will be slow, it's because Dart should be able to be faster than Javascript because it's easier to optimise. The creators of V8 are writing the Dart VM, so presumably they have some ideas about how to make it faster than Javascript.
- kibwen 15y agoGood points. To clarify, by "suboptimal" I meant that the Javascript code generated by transpiling a Dart application will almost certainly be less optimal than writing that application in Javascript from the outset. But, again, whether this will be an issue remains to be seen. If there does turn out to be significant overhead to the transpilation phase, I'm curious if a pragmatic subset of Dart will emerge that avoids any language features that incur expensive tranformation costs, sort of like how some modern Python projects (e.g. Django) handle 2to3 compatibility by avoiding language features that are incompatible across versions to achieve a more unified codebase[1]. [1] http://groups.google.com/group/django-developers/browse_thread/thread/abede3685ad0302 http://groups.google.com/group/django-developers/browse_thre...
- spankalee 15y agoTo clarify, by "suboptimal" I meant that the Javascript code generated by transpiling a Dart application will almost certainly be less optimal than writing that application in Javascript from the outset. My point is that this is not really true. The Dart language itself is designed to compile to efficient Javascript. This is one reason it's a better solution than GWT in my opinion, because Java does not always compile to efficient Javascript and you do have to skip features like longs, Java regexes, even the java.util collections classes are heavyweight. Dart being designed from the start to compile to Javascript avoids most of these problems. Like CoffeeScript, I expect Dart performance to be very close to Javascript when compiled, sometimes even faster than what a programmer would normally write.