Hacker News new | ask | show | jobs
by AndrewDucker 5356 days ago
It seems to me that Dart came out of the Java->JVM tooling that Google had with GWT, but with all of the bits that weren't useful to that end taken out.

If you start with Java, strip out everything that can't be mapped reasonably well onto JS, and tidy up what's left, then you have something that can be used to build statically typed applications for the web in the manner which Google are used to.

1 comments

It actually seems like Dart didn't reuse anything in GWT, other than 'lessons learned' - if it did, it would have the GWT compiler's dead code elimination, optimizations, dev mode, story of your compile, code splitting, etc.

I'm guessing it wouldn't be a good match because Dart is fundamentally closer to a dynamic language than a statically typed language

The similarities to java seem to come from conservatism in language design more than anything else.

A way to show differences is to say what steps would be involved getting Dart code to run on the JVM. As far as I can tell the only real difference is type erasure, so all you'd have to do is:

1) erase types. All method parameters become Object, all variables become Object.

2) implicitly add an interface to each class for each method type ie classes with String toString(String) get an implicit interface with one method Object toString(Object).

3) implicitly cast from Object to the method-interface type in order to call methods.

That sounds pretty slow, but also not very far from Java. I doubt it would take more than a day to make a prototype .dart to .java source converter that actually worked on JVM.