Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!

I've been a zone leader with DZone since 2008. I work as a technical lead on a next generation tool suite using based on Eclipse. This means that I get to use Java everyday, and a selection of the best Eclipse technologies, from EMF to GEF to Xtext. Along with all of this, I do iOS development in my spare time. James is a DZone Zone Leader and has posted 529 posts at DZone. You can read more from them at their website. View Full User Profile

Google's "Dart" on the JVM

10.18.2011
Email
Views: 6795
  • submit to reddit

Google's newest programming language can now be run on the JVM, thanks to the JDart project hosted on Google Code. Unveiled at the goto conference last week, the Dart language is seen by some to be suitable for Java developers who can't get into Javascript. The language is supposed to make it easy to create quick prototypes using structured code. Visual Basic for the web? We'll see. 

The JDart project is in it's early stages, with only a few instructions translated. The JDart compiler generates jar files to run on any Java 7 VM. The author has provided a few examples so you can see what the compiler actually generates. Here's the simple Hello World output. First the Dart code: 

main() {
  print("hello world");
}

Which gets compiled to the following:

public class test {
  public static void main(java.lang.String[]);
    Code:
       0: invokedynamic #18,  0             // InvokeDynamic #0:__main__:()V
       5: return        

  public static java.lang.Object __main__();
    Code:
       0: ldc           #21                 // String hello world
       2: invokedynamic #27,  0             // InvokeDynamic #1:print:(Ljava/lang/String;)V
       7: aconst_null   
       8: areturn       
}

It's very early days for Dart, and it has a long way to go if it has any chance of toppling Javascript. But if you've been messing around with the languages, perhaps this project gives you another reason to consider moving to it for your web applications. 

 

 

Published at DZone with permission of its author, James Sugrue.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)