Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the limits of compiling dart to javascript?

I know, that dart is still in technical preview. Dart can also be compiled to JavaScript.

But what are the limits of compiling dart to javascript? Dart has to have some specific features or concepts within the language, that can not just be translated to JavaScript code?

The reason is, that a friend asked me if Dart can compile everything possible to JavaScript or that e.g. 5% of the languageelements (you know, the really cool improved stuff) will not be compileable.

http://www.dartlang.org

like image 723
Gero Avatar asked Jul 20 '12 19:07

Gero


2 Answers

My startup has developed a 50.000+ lines application in Dart and have so far stumpled upon very few limitations with regards to compiling Dart to JavaScript. Dart was engeneered from the start to be converted to JavaScript so it does not suffer from the compilation issues that plagued GWT (allot of Java classes could not be serialized into Javascript by GWT, causing people to wrap stuff for no other reasons than to make the GWT compiler happy).

Having said that, there do exists a few limitations when compiling Dart to JavaScript but most of them are related to server side technology that cannot run in the browser like sockets and IO access and are thus very reasonable. There are also a few limitations with regards to passing objects to isolates, but I belive these will be sorted out in future releases of dart2js.

like image 166
Lars Tackmann Avatar answered Oct 13 '22 16:10

Lars Tackmann


May I include a FAQ quote? ;)

Q. Will any valid Dart code compile to JavaScript, or are there limitations? Yes, we intend for any valid Dart code to compile to JavaScript. If some support is missing from one of our compilers, that's a bug (in either the compiler or the spec).

So if it's not the case now, at least Google's goal is to compile any piece of Dart code to JavaScript.

like image 25
Alex Avatar answered Oct 13 '22 17:10

Alex