8

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

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

2 Comments

What Lars said. I'll add that currently, as of 2012-07-20, there is a known issue of compiling very very large sized integers (from Dart) to JavaScript. Dart supports arbitrary sized integers, JavaScript does not. This is a known bug, and the team knows about it. If you stay within JavaScript number sizes, you'll be OK. We intend to address this mismatch before Dart's release.
@SethLadd sorry yes I forgot about that one (that's why I have my own int implementation, but most people will never need this). Do you know if the JS int will become with arbitrary precision (like on the VM) or it will be constrained to 64bit JavaScript integers.
3

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.