I’ve starting converting a complex web app from being purely JavaScript and browser plugin based to using the Google Web Toolkit for the JavaScript part of the project. See my previous blog post about this.
Unfortunately for me, this project is not high enough priority to play with it for long periods of time. However, I have managed to start work and get some basic functionality working. It was certainly interesting!
I’m going to comment on a few of my first impressions. I’ll state a strong opinion now, but I reserve the right to change it completely as I get more experience with the library and tools.
Speaking of Tools…
Wow. This is really slick. You get to debug the Java code directly without looking at the JavaScript that it compiles to! Eclipse is a great editor for Java code, and GWT integrates nicely with it.
The debugger is nice, the compiled code looks good, and the warnings and errors that the development web server generates are extremely helpful. This is probably the strongest selling point for me with GWT.
Don’t touch the DOM!
This was a shock to me. The web browser’s DOM is an extremely efficient place to store information about the document you’re displaying. A heck of a lot of effort has gone into making this efficient and safe. CSS is an extremely powerful tool that is closely coupled to the document’s DOM.
GWT’s designers don’t want you to touch the DOM, though.
GWT gives programmers only limited abilities to write to the DOM, and they work extremely hard to make it difficult to read the DOM. For example, the DOM.setAttribute call can be used to assign a id attribute to an HTML tag. That sounds like a really useful call, doesn’t it? I could use that to make it easy for our graphic artist to design some CSS to describe the appearance of the application. It’s deprecated, though. You’re not supposed to use it. π
GWT is not for documents.
It sildenafil tablets australia is extremely effective, safe and affordable at the same time. That is why it is important that your physician takes a look at the medications that sildenafil tablets you take on a regular basis then, you can see a significant change in the attainment of orgasm. This helps the sildenafil tablet medicine to dissolve faster and start acting within less than one hour. It is readily available sale cialis in the leading pharmacies across the UK over the years. I shouldn’t be too harsh to GWT about the DOM, though. This might be obvious, but GWT is for complex, full featured applications that happen to reside in your web browser. It’s not for displaying documents. There are some corners of the library that allow you to put HTML directly wherever you want to, and I suspect they work great. They should even work with an external CSS file.
An application is not a document, and I might be having trouble getting over that. I’ll get back to you later when I form a stronger opinion.
Writing JavaScript directly?
If you want to do something that simply cannot be done through GWT, you’re in luck. GWT has a JavaScript Native Interface that is analogous to Sun’s JNI. It works great! I use it extensively to talk to my browser plugin, for example. It’s easy to use, and it doesn’t screw up the tools any more than they should be.
This, of course, allows you to create whatever back door you want to allow you to manipulate the DOM. However, until I get a better understanding of the GWT techniques, I’m going to try to do things the GWT way. I may have more to say on this subject later. π
There are back doors to get there, but it’s not a real GWT application if you rewrite their tools to do it your way. Instead, you do things the SWIG way.
GWT == SWIG
Yes, that’s right. GWT has more in common with a SWIG application than a JavaScript/DOM/CSS application. Is that bad? It’s certainly a great thing if you like SWIG. I don’t have much experience with it, so I don’t yet have a strong opinion.
However, I do think it’s a great idea to emulate a well used framework instead of writing a completely new one. There are a lot of SWIG developers and ex-SWIG developers out there, and I’d guess that they’ll feel pretty comfortable in this framework.
Documentation?
The documentation is fine, and I shouldn’t complain about it. However, I could have really used this blog post before I’d started. If you start out as a native JavaScript/Prototype/Ruby on Rails developer like I did, then what I’ve said here is not completely obvious.
The Google group is great, though. I’ve gotten responses to my queries immediately.