Monday, March 15, 2010

Google Web Toolkit (GWT): Uses and Limitations

Google Web Toolkit (GWT) is a web development toolkit is an AJAX framework developed by Google. It’s build using Java as baseline language and allows J2EE developers to implement AJAX behavior in their web application without being expert in
XmlHTTPRequest /JavaScript. GWT comes with it own compiler called GWTCompiler.  All the application development including UI is done using GWT libraries. Once the application is compiled using GWTCompiler, it produces the HTML, JavaScript as part of client side component.

Going little further in deep, an application is divided into tow parts namely client and server components. All the calls made from client to server are asynchronous. Please refer “Starting with GWT” for more details on GWT basic architecture.

Coming to its uses and limitations aspects, let’s go through its uses first and then the limitations.

Usage of GWT:

  1. GWT framework usage Java as baseline language and hence can be easily integrated into Java applications.
  2. Since programming constructs are very similar to Java, learning curve is very small.
  3. By default, all the requests made by client is asynchronous, the application with much complex client server interaction becomes much more efficient without much effort investment.
  4. GWT has plug-ins available for major IDE such as Eclipse, IntelliJ IDEA etc.
  5. GWT comes with its own testing server (Tomcat) called Hosted mode, and provides feature to quickly validate the functionality implemented right through the IDE itself.
  6. Since the application can be run in Hosted Mode from the IDE itself, debugging the application becomes very easy especially the UI components.
  7. Entire application including UI is developed using Java and Style sheets. No JavaScript, HTML is involved in a typical web application developed using GWT.
  8. All the internal URLs of the applications are hidden from the user/hackers and can't be accessed directly bypassing the entry point of the application.
  9. It supports custom calls of native JS functions if any, though not recommended ant not easy.
  10. Other features such as Internationalization (i18n), logging are well supported in GWT.
  11. GWT compiler optimizes the UI code automatically. It removes any dead code during compilation time. Also by setting split-points in the code, it can also segment any download into multiple JavaScript fragments, splitting up large applications for faster startup time.

This is only the first side of the GWT. Let’s look at the other side of it i.e. limitations of using GWT.

Limitations of GWT:

  1. All the client code should be clearly bundled with client package. If any server class is referenced in the client code, results into GWT compilation issue without a very clear message. This becomes trickier as both client and server java files are part of the same source code structure.
  2. GWT compiler output is not very clear and results into very high level compilation errors messages resulting into more effort into finding the root cause of the compilation error.
  3. Every call in GWT application is asynchronous so if there are any synchronous calls required, they have to be grouped in a single call otherwise need to be tricked with group of asynchronous calls.
  4. While writing client side code having multiple asynchronous calls involved, it becomes very tricky to uses out put of the first call into second call.
  5. It becomes more error prone when multiple asynchronous calls are involved in one user request. Developer uses class level variables to pass the details from one call to the other. This way the coding is done without any compilation error. Since the calls are asynchronous, we can’t guarantee the request processing time of individual calls. This leads into inconsistent behavior in the application. If not properly handled, the application may work/may not work as expected depending on the sequence of various individual asynchronous calls processing.
  6. Entire UI is developed using Java (GWT) and Style Sheets. This leads into same issues as servlets (UI elements tightly coupled in Java) and eliminates the advantage of having JSPs.
  7. If the code is running fine in hosted mode, but not running properly in real application deployment, it becomes very difficult to troubleshoot the code as the generated code from the GWTCompiler (which is actually running in production mode) is not very readable.
  8. All the UI is created using generated JavaScript; it becomes very sluggish in case of complex screens. Sometimes it even becomes unresponsive depending on the browser capabilities.
  9. Since all the calls are made asynchrous using JavaScript and also the application page is created using JavaScript, it results into browser alerts quite often stating the page performance.
  10. Creating a screen with complex page layout becomes very tricky as not all HTML elements are supported through GWT.
  11. Novice users result into excessive use of the UI components (various panes e.g. Horizontal Pane, Vertical Pane) and later get confused about their positions and usage as they can be instantiated at any place in the code but only appear in UI at place where added to the base component.
  12. No assistance from UI editors such as Macromedia Dreamweaver.
  13. Generated UI can’t be inspected for its UI components using any current UI inspectors such as IEInspector as all the UI is painted using DHTML/JavaScript.

To summarize, GWT is a very useful framework for application having simple UI with lot of client server interactions involved (where AJAX is a required/applicable feature). It’s not suitable for an application with few requests (one or two) per screen and especially if the screen layout involves huge number of screen components. Many of the times, I have seen wrong usage of GWT where we bear with its limitations but not able to utilize its capabilities. Hence before going for GWT in any application, its applicability should be critically evaluated.


  1. This is a very useful article, thanks for taking the time to type it up.

  2. Hi .... is there any popular sites which uses GWT functionality in them ? I'm a novice and I was wondering if people could use GWT's AJAX functionality in their web sites. If it is possible, please give inputs on that ....

  3. This comment has been removed by the author.

  4. As of now, Industry is moving towards AJAX behavior. In most of the organizations, AJAX in being used heavily in in-house tools and slowly it's appearing in mainline applications as well (mainline applications are hard to switch at once). If you look at GMAIL, YAHOO, GOOGLE SEARCH, FACEBOOK etc, all had changed recently with AJAX behavior. GWT is one mean to achieve such behavior.