Phine Solutions web work notes

Trying out Google Web Toolkit

Filed under: javascript — 1.618 @ 9:08 pm

After watching some Google IO keynote videos I got interested in Google Web Toolkit and played with it a little bit. It is quite an interesting tool. Basically the tool helps Java developers to develop JavaScript using the familiar Java programming language on familiar development IDE such as Eclipse. And probably more importantly, it takes care of the nittygritty details such as browser compatibility and code optimization. So one can write it once and be pretty comfortable about running the code on different type of browsers.

Unlike other Java to JavaScript frameworks (jMaki for example) that require actually to be hosted in a Java VM container, GWT produces the client side JavaScript code as a final product. So Java, in this case, is just a tool, not part of the end result. Of course, if there is server in the backend to handle the RPC calls,  Java Servlets can be used to facilitate that, but it is not mandatory.

GWT is not just a tool for Java developers who don’t like coding JavaScript. It also put AJAX into better perspective by separating the client and service code in the code base. Using JSON as the messaging protocol between the client and server, a GWT client application can talk to any web server that speaks the language, which doesn’t have to be implemented in Java. GWT also provides a way to work around SOP – the Same Origin Policy.

SOP is the security policy that is in the web browser to stop a client script to communicate with web server that the script is not originally from, in another word, any arbitrary web server. This is a necessary security measurement, but it makes the client less distributive. For example, a web service provider would like to distribute a small version of client script, which can be embedded in any web sites, and get the dynamic information from the service host. GWT handles this by requiring server to return JSON output in a “<script>” tag, and a callback function will also need to be defined to handle the output.

With the advance of web technology, JavaScript will play much bigger part in rich web applications in the future. I think the biggest strength of GWT is its capability to scale up the size of a JavaScript project. Following the Java’s footprint a project created using GWT can be better managed, tested and collaborated among developers.

One drawback is that one has to be familiar with Java. And obviously there is a little bit of learning curve on those GWT GUI APIs. Nonetheless it is a great tool for Java developer to natually adopt and use to create some great JavaScript applications.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

©phinesolutions.com