From GWT to greener pastures

by Michael

Google Web Toolkit (GWT), a development framework for web applications that allows one to write Java code for the web by compiling it to JavaScript. We were using an older version of GWT together with an incubator library for creating tables. These tables became a stable part of the entire web application.

We had a few issues:

  • making changes during development meant waiting for 20 seconds to see the effect – GWT has to reload the code in “hosted mode”
  • “hosted mode” is not production mode, regular expressions for example, work differently in hosted (Java environment) and in production mode (JavaScript environment)
  • the incubator library did not support later versions of GWT, we were locked in unless we wanted to convert all table code
  • future support for GWT is questionable (GWT team now working on Dart)
  • it is a bit niche, hard to find questions and answers compared to other frameworks
  • GWT RPC is not human readable nor sane

At some point we decided that we should make an effort to make GWT upgradeable, which meant replacing all the tables – which actually meant rewriting the entire application. Given some of the problems mentioned above would not be alleviated by upgrading, I decided to write a report that weighed the pros and cons of staying with GWT and presented this to our team. Based on this report we decided to plan how we could migrate away from GWT to a less niche web framework collection.

We would be incrementally adding new components using the new framework, replacing GWT components with the new framework and eventually removing GWT all together. Through this transition, we would need to facilitate communication between GWT and the new framework in order for GWT to invoke displaying components in the new framework and vice-versa. We created a so called Native Event Bus written in JavaScript that allowed us to write GWT native JavaScript which interfaced with this Native Event Bus. The new framework did the same thing. This created a communication bridge between GWT Java code and the new JavaScript based framework.

Once the Native Event Bus was in place, we were able to create components using the new framework and place these components inside GWT components and vice-versa. We’re no longer developing new components using GWT. Having the near immediate feedback, not having to worry about Java vs. JavaScript, being able to use sane server communication like REST, simply doing web development in a normal way is just great!

The new framework consists of a collection of libraries such as: backbone, asm, jquery, mustache – libraries that: had substantial documentation compared to alternatives, community support and considered generally accepted within the web development community.