GWT is a software stack that translates Java code and a sub-set of the Java Runt
ID: 650778 • Letter: G
Question
GWT is a software stack that translates Java code and a sub-set of the Java Runtime's class library to JavaScript code.
In comparison with JavaScript toolkits, GWT can seem alienating, by nature and by usage, and overly complex to do even simple things, taking away much of the fine-grained control you'd have by using JavaScript directly.
Why would a web-developer choose to use a tool like GWT, which uses a language originally not targeted for the web, instead of using pure JavaScript and JavaScript frameworks and toolkits?
Is it measurably better, and based on what criteria?
Explanation / Answer
Batteries Included
Java's Tooling
It is just awesome:
IDEs: even if some IDEs support JavaScript, the level of support just doesn't compare. Try to refactor JavaScript code on large codebases (say, 40K+ LOC) and weep.
Unit-Testing: though that picked up over the last few years, it's also way more mature in the Java world.
Continuous Integration and Continuous Inspection
Documentation Generation: Sure you have JSDoc and a few others
Static-typing
It catches bugs early. (Google Closure address that a bit while keeping the developer in the JavaScript world, if you prefer).
Optimized JavaScript
GWT writes faster and more compact JavaScript than you (for large applications), and allows you to determine what gets sent to the client arguably more easily than with equivalent full JS solutions.
Architecture
It provides a good separation of concerns for large applications, with decent MVC or MVP architectures already pre-baked at your finger-tips.
Decent Library
GWT provides interesting libraries, and makes it easy (well, easier) to build I18N-enabled applications with dynamic bundle loading.
Unit-Testing
Using JUnit from within Eclipse IDE and from the command-line. This relates to my first point. You could very well also use some of Java's code quality tools on a GWT project (for source checks, not bytecode checks, as there isn't any).
It's All About YOU!!
GWT isn't for everybody. It makes some people more productive and gives a good tool for non-JS developers to build professional web-apps with dynamic front-ends without touching (too much) JavaScript. But if it doesn't work for you, just use something else.
If you want most of the above but you just don't want Java, maybe look at Google Closure, or the Dojo Toolkit.
Was a Good Idea at the Time: History Matters!!
The JavaScript world (and web front-end technologies in general) is extremely active these days, so things are looking up. But only a few years back, things were not so bright. LESS/SASS were not that popular, jQuery was not yet the de-factory JS library, JavaScript libraries weren't spawned every other week, and tooling wasn't that great in general.
But, there already was a growing demand for professional and large web-applications with dynamic front-ends, so there was a gap to fill to make developers more productive. JavaScript has a great many pitfalls and oddities that you need to be aware of, and maybe it's just better to not even need to care about them. Hence the niche for tools like GWT.
Since then, others have appeared (CoffeeScript comes to mind, Dart is on its way, but also large JavaScript frameworks, the revolution of server-side JS with Node.JS and others, and a strong comeback for JavaScript as "good enough" all-around language to be used not only on the client-side but also in other parts of your business stack.
Additional Notes
With Regard to your Original (Now Edited) Question About the Use of Firebug
You can debug GWT code with Firebug of course, but ideally you would debug it directly from the Eclipse IDE's debugger, which now provides live code debugging support.
However, Firebug it still usable, though you need to keep in mind that GWT generates optimized and compressed JavaScript, which may not be easy to debug as is.
With Regard to your Original (Now Edited) Question About CSS
Yes, you still need to write CSS code yourself, of course. You couple your GWT project with other tools though (like SASS), more or less easily.
It's Just a Tool!
Don't mistake GWT for what it's not: you don't write Java code to be run directly on the client side as Java bytecode. You write code in the Java language, which is then translated to JavaScript for efficiency and to allow you to use a higher-level language (or, at least, that's how it's meant to be seen).
Arguably, Java and JavaScript could be regarded as comparable in terms of abstraction levels. However, Java comes with some advantages (detailed above), hence the advantage in reaping the benefits of existing tools without the need to re-write them. Google's developers just had the clever idea of making it possible to reuse existing Java-oriented tools, but to in effect develop JavaScript applications.
Additionally, they solve another issue, which was the often cumbersome managed of dual-language web-applications where the JavaScript and the Java code was treated separately. The use of GWT allows a certain level of convergence for both sides of the development process.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.