devxlogo

The Google Web Toolkit’s AJAX Recipe: Less JavaScript, More Speed

The Google Web Toolkit’s AJAX Recipe: Less JavaScript, More Speed

an Francisco, CA?How popular is the Google Web Toolkit (GWT)? Google claims their Java web development framework for AJAX (asynchronous JavaScript and XML) applications has been downloaded millions of times since being launched during the JavaOne Conference in May 2006, but perhaps a better indication of its popularity is that Pearson Education dedicated an entire conference to it: Voices That Matter: Google Web Toolkit, a four-day affair for Java developers here this week. The 175 attendees exceeded Pearson expectations by 25.

In a media briefing at the conference, Google Engineering Manager and GWT co-creator Bruce Johnson explained the mission his team undertook when Google open sourced GWT under the Apache 2 license in December 2006: create a better user experience by enabling Java developers to create high-performance web applications using only the Java tools they know rather than trying to master the JavaScript skills that are necessary for creating responsive web interfaces for all the browsers out there. As Johnson describes it, the state of the typical web application today leaves a lot of room for improvement. “The average usability of web sites sucks,” he said, citing all-too-familiar examples of web user headaches:

  • A mortgage application that requires the user to complete a 12-page application, but mandates “Don’t Hit the Back Button” because the site’s AJAX implementation breaks that function?if a user realizes he or she made a mistake on a previous page, the user is stuck.
  • An e-commerce site warning that a user’s credit card will be charged twice if he or she presses the Submit button twice, yet the site just hangs while processing the initial submit click and offers no confirmation in the meantime
  • Of course, the 404 (page not found) and 500 (internal server) errors with which every web user is familiar

“These are implementation details that surface as usability problems,” explained Johnson, adding that browsers are powerful enough to run the JavaScript code in the first two of the above examples correctly but Java developers with little or no JavaScript experience don’t know how to implement it properly.

How do these complex JavaScript development requirement tasks fall to an inexperienced Java developer? Johnson offered an example. Suppose a product manager asks the development team in a “Web 1.0″ Java shop (i.e., Java, JSP, Struts, etc.) to add a little JavaScript?”just a couple of lines”?to an application. When the team successfully implements that functionality and receives positive feedback from users, the sales team then considers their shop an “AJAX shop” and begins promising support for all users, resulting in “a landmine of compatibility problems for browsers,” according to Johnson.

As Firefox, Safari, and even mobile device browsers begin to demand the same functionality that those couple of JavaScript lines provided, developers try to programmatically make their applications compatible by hand-coding the JavaScript and quickly find themselves out of their depth. In this scenario, said Johnson, the developers are caught between what’s easy and maintainable for them (limited browser support) and what’s best for the user’s experience (cross-browser support).

GWT’s goal is to free Java developers from having to make that choice by taking the client-side scripting out of their hands. GWT is composed of two components: an AJAX widget library and a cross-browser compiler that converts Java code into AJAX. Java developers can use each component independently if they choose to, but they don’t have to write a single line of JavaScript code by hand.

The Need for Speed
When asked to differentiate GWT from other freely available AJAX toolkits and frameworks such as Dojo, Prototype, and jQuery, Johnson emphasized Google’s commitment to making AJAX faster and smaller (i.e., containing less JavaScript code). The GWT team uses a benchmarking subsystem to measure the performance of its compiled code for any given browser permutation, which enables them to “optimize like crazy.” The result is an application like GWT mail sample, which Johnson cited for its speed. And for GWT development occurring outside of Google, he pointed to the process-mapping software Lombardi Blueprint as a showcase of GWT functionality.

The ultimate goal, said Johnson, is for GWT to produce faster and smaller compiled AJAX code than a JavaScript expert could write by hand, which could happen as soon as Q1 of 2008 when version 1.5 is due for release. As to how GWT compares with the other AJAX toolkits, Johnson said he and his team try to make GWT compatible with them all but also jabbed that, “I can use my wrist watch to time [the responsiveness of] some of the widget toolkits out there.” He wouldn’t name the particular toolkits he was referencing.

When GWT 1.5 arrives, Johnson said it will also offer full language support for Java 1.5 (Generics, etc.). This feature would enhance the current 1.4 version’s features, notably AJAX internationalization, which uses message templates to enable developers to compile code for 400 locales from one code base, and browser history support.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist