Tuesday, January 11, 2011

GWT And Why It's Awesome

I am enjoying using GWT at work. GWT basically takes Java code and compiles it into AJAX-capable Javascript. GWT lets you use nice Eclipse features (like code completion and various wizards) and gives you a lot more compiler safety (like type safety).Of course if you want to handwrite some Javascript, you can do so using the Javascript Native Interface (JSNI). One particularly useful feature of GWT is AutoBean. AutoBean lets you automatically create Java objects from JSON input. It handles all the parsing details for you. :)

When you're ready to deploy, GWT will compile your Java into optimized, cross-browser(!) Javascript. It actually creates a separate version of the code for every browser, and then loads the correct one at runtime.

GWT is still quite young, so there are still a few bugs hiding. Today we found a (minor) bug that forced us to change our JSON format. Apparently, AutoBean doesn't handle '-'(dash) characters in JSON very well, even though it's a legal JSON character. GWT will try to create a Java/Javascript variable name with a '-' in it, and this causes parsing exceptions. I'll report this at some point soon.

Even with a few rough edges, GWT seems like it really accelerates web development. You should give it a try.

3 comments:

  1. Interesting piece of software will take a look.

    ReplyDelete
  2. You should run the results through Rhino and see what you get back.

    ReplyDelete
  3. Sounds like a really nice environment for web development, with some handy tools/APIs. Glad that Google doesn't hate you. ;)

    Also, GWT isn't the only thing that has trouble parsing JSON. Crazy trailing commas and all...

    ReplyDelete