GWT: First Impressions

Last Friday, I spent the day playing with the latest release of the Google Web Toolkit, or “GWT”, thanks to a great boss who believes in giving developers time to stay current with new developments in the ever-changing web dev world.

I must say, this experience was a very refreshing change from so many other web development “frameworks” that have sprung up in recent years. Unlike others we’ve looked at (e.g. Struts 2 and Grails), GWT is extremely well-documented; the tutorials are well-constructed and easy to follow, and the class documentation is very complete and logically laid-out. The toolkit itself is quite mature and so far, everything works “as advertised”. By contrast, other web dev frameworks have spotty documentation written by early adopters and scattered all over the Web. The importance of good documentation for web frameworks cannot be overstated.

GWT seems clearly aimed at Swing developers wanting to create rich web applications that deploy in a browser. It allows developers to write all of their UI code in Java, freeing them from dealing with the plethora of incomplete javascript frameworks such as prototype and script.aculo.us. It lets you lay out your application programmatically with Widgets and Panels, which is old hat for Swing developers, but is probably a big hurdle for web designer types. Indeed, GWT is all about designing web applications. It’s overkill for marketing-oriented web sites that just want a little interactive “sizzle”.

Here are Google’s answers to the question “Why translate Java code to JavaScript?”. I happen to completely agree with all of them!

  • You can use all of your favorite Java development tools (Eclipse, IntelliJ, JProfiler, JUnit) for AJAX development.
  • Static type checking in the Java language boosts productivity while reducing errors.
  • Common JavaScript errors (typos, type mismatches) are easily caught at compile time rather than by users at runtime.
  • Code prompting/completion is widely available.
  • Automated Java refactoring is pretty snazzy these days.
  • Java-based OO designs are easier to communicate and understand, thus making your AJAX code base more comprehensible with less documentation.

Order for the free viagra without prescriptions uk sample pack by visiting our product section and receive the medication directly to your doorsteps. Holiday fun can include a large group road trip with an Atlanta charter bus company. getting viagra in australia As a matter of fact, it is superior to the frozen berry as it contains all the necessary components inside it and is also fulfilling all tadalafil 20mg canada the possible conditions. DOSAGE- It is always advised to use these cialis in india price pills after consultingyour doctor or your healthcare professionals.

For me, the most compelling features of the GWT are:

  • Really simple RPC – To communicate from your web application to your web server, you just need to define serializable Java classes for your request and response. In production, GWT automatically serializes the request and deserializes the response from the server. GWT’s RPC mechanism can even handle polymorphic class hierarchies, and you can throw exceptions across the wire.
  • Browser history management – No, AJAX applications don’t need to break the browser’s back button. GWT lets you make your site more usable by easily adding state to the browser’s back button history.
  • Real debugging – In production, your code is compiled to JavaScript, but at development time it runs in the Java virtual machine. That means when your code performs an action like handling a mouse event, you get full-featured Java debugging, with exceptions and the advanced debugging features of IDEs like Eclipse.
  • Browser compatible – Your GWT applications automatically support IE, Firefox, Mozilla, Safari, and Opera with no browser detection or special-casing within your code in most cases.
  • JUnit integration – GWT’s direct integration with JUnit lets you unit test both in a debugger and in a browser…and you can even unit test asynchronous RPCs.

    For those interested in diving in, I highly recommend reading the Overview first. There are some very important basic concepts to get your head around. For instance:

    GWT applications can be run in two modes:

    • Hosted mode – In hosted mode, your application is run as Java bytecode within the Java Virtual Machine (JVM). You will typically spend most of your development time in hosted mode because running in the JVM means you can take advantage of Java’s debugging facilities and remain within an IDE like Eclipse.
    • Web mode – In web mode, your application is run as pure JavaScript and HTML, compiled from your original Java source code with the GWT Java-to-JavaScript compiler. When you deploy your GWT applications to production, you deploy this JavaScript and HTML to your web servers, so end users will only see the web mode version of your application.

    Google has added a lot of built-in support for Eclipse. Since we use IntelliJ, I was interested in trying out the GWT support in IntelliJ, but I hit a major stumbling block right off the bat. The JetBrains guys created a nice video tutorial to show off their GWT support, but it’s based on an older version of IntelliJ. The method for setting the path to the GWT SDK is completely different in 7.X. There is no global GWT IDE setting; instead, you have to open up the Project Settings and configure the GWT “facet”, as shown below.

    All in all, I’m very impressed, and looking forward to building something “real” in GWT soon!

6 thoughts on “GWT: First Impressions

  1. I’m a fan of both GWT and Grails. I’d have to disagree with your statement about Grails not being well documented. It’s extremely well documented and has both a great online tutorial/reference guide and a very active mailing list. In fact, using Grails and GWT together is a great end to end solution.

  2. Not surprisingly, I totally agree with all what you wrote. If you have previously done it in the hard way (trying to glue Js libraries together with DWR and other rubbish stuff) then GWT is what you need.

    Regards,
    Zaid

  3. Thanks Dean! I based my comparison of GWT & Grails documentation on a “first impression” after spending only one day with each of the technologies. Granted, it’s hardly fair to compare GWT vs. Grails given the vast resources Google has at its disposal. Grails desperately needs one person to “own” their documentation. A cohesive overview of its basic concepts would be extremely helpful. Also, the tutorials page (http://grails.org/Tutorials) contains many links outside of grails.org. The style and quality of these tutorials is inconsistent.

    I agree that Grails + GWT is interesting. I wish the two were already integrated under a single framework! I’ll certainly give http://grails.org/GWT+Plugin a look.

  4. I recently spent a few days looking at GWT and Grails myself. My conclusion was that Grails, being a “convention-based” framework imposes a much higher learning curve than GWT attempting to build anything non-trivial. Both products have great support for plugging in new UI components but once again GWT come out on top due to their commitment to strongly type interfaces and great APIs.

    Don’t get me wrong. I feel that Grails, and Groovy as a language, have awesome potential and will undoubtedly change the landscape for a new generation of rapid development toolkits. Unfortunately, the reality is that both tooling and product maturity are key qualities of any truly pervasive technology and Grails/Groovy are lacking on both counts (with the exception of the Groovy editor in JetBrains which I hear is phenomenal).

  5. Thanks for the comment, Jose. As mentioned previously, I see Grails and GWT as potentially complimentary technologies: Grails for the back and and GWT for the UI.

Leave a Reply

Your email address will not be published. Required fields are marked *