Google Web Toolkit

Thursday, 18 May 2006

Google have released the Google Web Toolkit — “Build AJAX apps in the Java language”. At first I thought this might just be their version of the Yahoo UI Library, but it turns out to be a completely different approach to the same problem. The YUI Library (and most other Ajax libraries) allow you to build a Web UI directly, using HTML and JavaScript. With GWT, you write a GUI application in Java, and GWT translates it into JavaScript and HTML for web deployment. It’s a less flexible approach, but could make it easier for Java developers to develop web applications with desktop-style GUIs — if this is what they really want.

I distinguish three different styles of application user interface:

  • Desktop: Rich UI widgets, very responsive, minimal dynamic effects. For example, Microsoft Word or any traditional desktop application.
  • Web 1.0: The traditional web site. Basic UI widgets only, slow response (with frequent full-screen refreshes), no dynamic effects. For example, this website. 🙂
  • Web 2.0: Ajax style. Rich UI widgets, very responsive, dynamic effects such as fades and slides. For example, Google Maps.

Not all Web 2.0-style UIs are on the Web, and not all Desktop-style UIs are on the desktop. Picasa 2, the photo management application, is a good example. It’s a Windows desktop application, but it definitely has a Web 2.0 interface with a lot of movement and use of colour and fades. Such an interface may not always be appropriate, but the visual approach works beautifully (literally!) in this case.

Now, most Ajax libraries or frameworks allow you to develop web applications with Web 2.0 interfaces. GWT, on the other hand, seems to enable building web applications with desktop-style UIs. It’s an interesting approach that might make it easier to concentrate more on functionality and less on snazzy visual candy. So you get layout widgets, trees, menus, frames; but no yellow fades, sliding panels or other dynamic effects. However, sometimes the “candy” is appropriate, and there’s no easy way to incorporate other JavaScript libraries. (Some brave soul might like to try using GWT’s JavaScript Native Interface; you could probably write a Java wrapper for some JavaScript Ajax library. Good luck to you.)

For many, the heart of Ajax is asynchronous server communications. GWT includes RPC functionality, but it’s pretty bare. For example, GWT and Scriptaculous both allow you to fetch data from a server; Scriptaculous will automatically populate a div with the data, but the GWT code sample simply has a comment saying “do some UI stuff to show success”. You’re on your own; it really is like building a desktop GUI application. And of course, since you write in Java, you have to declare a serializable Java class for each type of message you need to exchange with the server. Ruby on Rails it ain’t.

(In a similar vein, I discovered Morfik Chess the other day. This is a nice chess UI and chess-playing computer implemented in JavaScript. An impressive achievement, made even more noteworthy by the fact that it is apparently written in Object Pascal and compiled into JavaScript. The last time I used Object Pascal was in 1990; I’m glad to see it’s still around.)

If you’ve already used other Ajax libraries or frameworks, you might wonder why anybody would want to use an opaque, inflexible toolkit like GWT to develop web apps. But if you’re a Java programmer who feels a bit daunted by multi-browser support, DOM and JavaScript, GWT could make it easy to put your application on the web.

Tags: , , ,


You can leave a comment, or trackback from your own site.

Leave a comment