If I understand correctly, both GWT and Google Closure are JS API's for building web applications. What is the difference between them?
1 Answers
Closure is a JavaScript library (really more like a collection of libraries, but that are all packaged as a single library and that can be imported using goog.require
from the base library). Closure simplifies a bunch of common JavaScript tasks in a way that is compatible with multiple browsers. Closure is also a JavaScript compiler that can both minify and optimize JavaScript code.
GWT is a Java toolkit (and associated libraries) that can take code written purely in Java, and convert it into HTML, CSS, and JavaScript, allowing a web application to be written purely in Java (but served as a real, HTML5 website, rather than as an annoying, slow-to-load Java applet).
A project written in GWT can make use of the Closure library and can include JavaScript code. However, Closure is really targeted toward developers writing JavaScript, while GWT is for Java developers.
To summarize...
Use Closure when:
- You are writing standalone JavaScript code.
- You are writing JavaScript that you connect with GWT via the "JavaScript Native Interface" (JSNI).
- You prefer rolling your own HTML, CSS, JavaScript.
Use GWT when:
- You are developing new or large web applications.
- You have a preference for writing code in Java.

- 93,612
- 16
- 138
- 200
-
2I wonder, if Closure and GWT use (part of) the same code base/library to generate the minimized/obfuscated JS result? – Chris Lercher Sep 27 '11 at 12:55