Google's GWT continues to amaze and delight

Javascript as a language misses a lot of the constructs that modern day object orientated languages have. Defining a class in Javascript is not an exact science, with a number of design patterns put forward to mimick behaviour. The biggest problem Javascript has is that its not compiled, so you never know if you have it right until you hit the "refresh" button in the browser. A single curly bracket or semicolon in the wrong place and the whole place can come crashing down around you.

However, the whole proposition of producing Javascript with another language (say Java) seemed a little 'round the houses' for me. I couldn't fathom why you would want to do such a thing. But after a year of hacking in and around ExtJS and other frameworks, you soon realized that Javascript is just one big hack. It's a wonder it runs at all!

Java on the other hand has all the necessary OO toys (classes, interfaces, inheritance, polymorphism). These are the building blocks that make any large software project much easier to handle. Of course, with the language being compiled, it is much easier to catch errors before you even get anywhere near deploying.

Imagine coding Javascript applications in such a way that you had all the flexibility of Java, coupled with the easy deployment of Javascript. That is precisely what GWT is.

So what drove me to try GWT?

Well it was the management of the ExtJS project. This used to be an excellent framework with lots of cool widgets that really made your browser dance and sing (also groan under the weight of it at times). Utilising ExtJS in any project is a commitment, and its not just a case of throwing some Javascript calls to it. It's the classic story, gets you 80% of the way in 20% of the time, with the rest taking up the time.

That is fine, as with most frameworks, once you've gone so far, you are locked into that framework for that project. It is generally very hard to switch out a framework at the 11th hour, particurly if its a UI based framework. So, going down the ExtJS route, you are pretty much pinning your colours on their flag pole.

The biggest problem with ExtJS is that they didn't respect backward compatiability at all well, which is a little frustrating considering they released relatively often. Moving from 0.4 to 1.0 required a rewrite. Moving from 1.0 to 1.1 required replumbing. Moving 1.1 to 2.0 required major rewrite, and again from 2.0 to 2.1 it wasn't a case of dropping in the new JS files.

Now with ExtJS 3 looming we couldn't face having to go back to the drawing board. We know there are bugs that were going to be fixed, but the hassle of continually porting for each release was costing us real money. Also it was getting difficult to tell clients why they had to spend money on porting to a new version that wasn't buying them anything.

After talking with someone who had seen the GWT dream he took me through the reasons why I should really give it a chance. Within one day, I was hooked.

Google has defined an API to which to code to and this API isn't for changing. They have also ported the most useful packages of Java over to Javascript. So imagine my delight in being able to call .trim() on a string without having to resort to some Javascript regex hack, or using any of the Collections classes (hashtables, linked lists etc) to manage my internal storage. I can also use all the Java OO techniques, and Google provides all the necessary 'conversion'.

Google has thought about everything, including communicating back to the server. Imagine being able to pass the same object to the server from the client (javascript), do something to it, and pass it back, all without you having to worry about the 'plumbing'. They provide a servlet framework to utilise to allow this magic to happen. Sometimes I think I am dreaming!

Here's the real kicker for me. In the time I have been using it, Google has rev'd 3 times (2 bug fix releases and one major update) and each time I merely dropped in their new JAR, recompiled, and my application worked. No change required! Now I can bet the farm on GWT. My team is now trained up in GWT and shock horror, some are even producing JUnit tests! JUnit tests for code destined for Javascript! Its crazy!

Google's 1.5 release is pretty slick; they have added a lot of serious optimizations and the final produced Javascript is even smaller and faster than 1.4. So as a result, my Javascript software is now smaller and faster, without me having to do a thing!

Andy and I have begun to integrate the GWT stack within Open BlueDragon to provide some of the handling of the new client side tags that have been introduced. By utilising Google we can be sure we won't have to keep recoding this area and it should be easier for people to contribute to if they want, especially, with some of the community GWT projects popping up. <cfcanvas> anyone?

I am also looking at making CFML objects available to the GWT frontend by transparently marshalling it in and out as it moves from GWT to your CFC/CFML request. That way you don't need to mess around with JSON and try to work around some of the limitations that imposes (dates anyone?)

If you have checked out GWT then I urge you to give it a whirl, you will never look at another framework in the same way again.


Recent Cloud posts

Recent JAVA posts

Latest CFML posts

Site Links