Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Interview: Bruce Johnson discusses Google Web Toolkit

Interview: Bruce Johnson discusses Google Web Toolkit

Google Web Toolkit (GWT) tech lead Bruce Johnson discusses the design of GWT, how GWT converts Java into JavaScript, community involvement with GWT, new features in GWT 1.4, and the philosophy behind GWT.

Watch Bruce Johnson discusses Google Web Toolkit (11 minutes).

From the interview:

I guess maybe people's first impression was: "This is a sort of translator"; it was a little dismissive until they got to see what it was really doing under the covers. They assumed that we were somehow blindly translating a particular Java construct into something in JavaScript, so that it would lead to bloated code and so on. Actually we take a much more computer science-y, and more aggressive approach to that which is that we parse all the Java source together and do some pretty aggressive optimizations on it. We disallow reflection and dynamic class loading, intentionally. The advantage of that is you can do whole-program optimizations when you know that there aren't pieces that are not analyzable by the compiler. Reflection kind of defeats full static analysis since you never really know what is going to happen until runtime, but if you take that out of the equation, you can compile a large source code base of Java and if you compile it monolithically then you can analyze every single call site, every method implementation.

You can identify things that appear polymorphic but really aren't, we call that "type tightening". Once you do that you eliminate polymorphism, you rewrite call sites and translate polymorphic dispatches into static dispatches and once you do that you can inline the code which allows you to do another iteration of other optimizations. So it is a real compiler and we've really only scratched the surface with the optimizations I mentioned and there are a lot more cool optimizations that we can do in the future. The benefit to GWT users is that all they have to do is upgrade the new version of GWT, recompile and they get a huge benefit in either size or speed or both. For example in 1.4 which is the next upcoming GWT release, a simple recompile will gain you about 20% size reduction and faster start-up time.

Rate this Article