

Dart to JVM bytecode compiler - DanielH
http://code.google.com/p/jdart/

======
georgemcbay
Nice project. Not sure how useful it is currently in the real world.

(This sort of goes off the topic, sorry)

It sort of reopens my bewilderment that Dart doesn't already do this, and a
lot more. I was expecting the language to be a lot more baked than it actually
is and expecting a lot of targets perhaps via an llvm translator.

I realize it is still early days for Dart but as a big fan of haxe (which is
similar in the sense that it is an ECMAScript-looking language with a custom
VM (neko) and the ability to compile to other languages (not just JS, but php,
C++, AVM1/AVM2 (Flash) bytecode, etc), I sort of expected the mighty Google to
have more to show.

haxe has a pretty good headstart, for sure, having been around for years, but
OTOH until very recently it was pretty much a one man show.

------
skrebbel
Surprise! Dart was actually Java all along!

------
AndrewDucker
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.

~~~
grimlck
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.

~~~
0xABADC0DA
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.

------
moomin
I think it's telling it generates better JVM code than Javascript.

------
eblackburn
How long before the IL generator?

