Google Cleans Ajax for Java

You’ll be hard-pressed to find a programmer who thinks programming in JavaScript is easy, or for that matter likes doing it. But it’s a necessary evil for many programmers to learn JavaScript, especially with the advent of Ajax and hot applications that use it, like Google Maps and Gmail.

So leave it to Google , which made Ajax a hit, to provide developers with a simpler way to create Ajax applications. The Google Web Toolkit (GWT) released this week is a framework that converts a standard Java application into Ajax that will work in all browsers.

“Programming in JavaScript is a real nuisance,” said Bret Taylor, product manager for Google’s developer program. “Depending on the scale of app you’re creating, you quickly realize that a scripting language that’s implemented differently in each Web browser is not an ideal environment in which to work.”

By way of example, it took Google, which has a sizable share of JavaScript programmers, more than a month to get Google Maps working properly in Apple’s Safari browser, even though it worked just fine in Internet Explorer and Firefox, said Taylor.

GWT works with any standard Java IDE to convert a full-blown Java application to JavaScript, while paring down the application and removing classes and functions not allowed in the more restricted browser environment. JavaScript applications, for instance, don’t have access to the computer’s file system, while Java does.

In converting the application, GWT makes sure that it will work with the major Web browsers, all of which implement JavaScript and XML differently from each other. It’s this incompatibility across browsers that’s the major headache for writing JavaScript applications and a major benefit of GWT.

By working with popular Java IDEs, like Eclipse, IntelliJ, JProfiler, or JUnit, developers have their full Java programming environment in front of them to test and debug the application. There are no real JavaScript IDEs for things like syntax and code checking. GWT comes with a set of UI components, called Widgets, to construct the UI elements in an Ajax application.

The main benefit, then, of GWT is being able to produce Ajax applications that support all browsers quickly and writing it in a professional Java IDE. “The benefit of having all those platform and browser quirks covered in a single point of entry that you run your app through is extremely powerful,” said Taylor.

A lot of Java developers don’t know JavaScript, so GWT will be a real help in building Ajax applications, said Dick Wall, principal software engineer for New Energy Associates, a division of Siemens. Wall is also a member of the Java Posse and the group has been discussing GWT a lot on its Podcasts from Sun’s JavaOne conference this week.

“What’s exciting is you don’t need to know [JavaScript] any more,” he said. “It’s basically like writing an AWT Java app and all of the translations to JavaScript are handled for you. It’s exciting because it removes a lot of the considerations that you normally have when trying to do an Ajax Web UI.”

Wall said many people look to Google as an Ajax community leader because of its success with Maps, Calendar and Gmail, so anything they do will warrant a lot of attention and hopefully encourage more Ajax development.

GWT still needs some fixing, Taylor said, first and foremost on the list being native Mac OS X support for development. Opera support could be tuned up and there needs to be better support for drag and drop development, all of which will come in future versions, he said.

Get the Free Newsletter!

Subscribe to our newsletter.

Subscribe to Daily Tech Insider for top news, trends & analysis

News Around the Web