If you’ve been keeping up on my ramblings on the blog related to RIA development and the various contenders in this space, you have probably read some very positive comments from me regarding Google Web Toolkit – along with the admission that my experience with it has been limited. Last night I decided to give a real application a go and dive into one of their example applications, the DynaTable Example. On the screen it looks pretty slick, and demonstrates some of the cool asynchronous stuff GWT can help you pull off.
But the more I dove into the application and started to change stuff around, the more I started to realize how hard this was to work with when compared to a similar application written in either Flex or OpenLaszlo. Not being as familiar with GWT as I was with Laszlo or Flex, it took me a little while to figure out where everything was in the application. Eventually, the code made sense to me, as I saw each of the components instantiated and arranged in Java. But for me, the fact that it took me five minutes just to figure out where the buttons were in the application was strike one. Strike two came when I saw how much code was required to create a simple navigation bar:
private class NavBar extends Composite implements ClickListener {
public final DockPanel bar = new DockPanel();
public final Button gotoFirst = new Button("<<", this);
public final Button gotoNext = new Button(">", this);
public final Button gotoPrev = new Button("<", this);
public final HTML status = new HTML();
public NavBar() {
initWidget(bar);
bar.setStyleName("navbar");
status.setStyleName("status");
HorizontalPanel buttons = new HorizontalPanel();
buttons.add(gotoFirst);
buttons.add(gotoPrev);
buttons.add(gotoNext);
bar.add(buttons, DockPanel.EAST);
bar.setCellHorizontalAlignment(buttons, DockPanel.ALIGN_RIGHT);
bar.add(status, DockPanel.CENTER);
bar.setVerticalAlignment(DockPanel.ALIGN_MIDDLE);
bar.setCellHorizontalAlignment(status, HasAlignment.ALIGN_RIGHT);
bar.setCellVerticalAlignment(status, HasAlignment.ALIGN_MIDDLE);
bar.setCellWidth(status, "100%");
// Initialize prev & first button to disabled.
//
gotoPrev.setEnabled(false);
gotoFirst.setEnabled(false);
}
//Handlers omitted for brevity...
}
Say what?!? That seems a little excessive, don’t you think? The equivalent code in Flex would be something like the following:
<mx:HBox horizontalAlign="right" width="100%">
<mx:Button label="<<"/>
<mx:Button label=">" enabled="false"/>
<mx:Button label="<" enabled="false"/>
</mx:HBox>
This is a shortcoming of GWT I initially glossed over in my evaluation of it. I was so excited at the prospect of turning Java-based tools on user interface logic that I forgot how verbose and complex Java code can be, especially when trying to accomplish certain seemingly simple tasks. OpenLaszlo and Flex employ as their language syntax a combination of XML based markup and scripting, which are much better at creating UI code that is human-readable. XML markup is naturally nested, and as such it is easy to see how components fit together and are going to be arranged on screen. When procedural logic is necessary, you can supplement that markup with scripting. Java is a much more powerful language to do that procedural work, but it really falls flat when you try and arrange a UI.
So it seems that the moral of the story is that the power of Java that GWT offers comes at a price paid in code density and readability, which manifests its self in your organization’s bottom line in developer productivity. Java has the best set of development tools out there, but I can see that I will need to use ALL of them to stay productive writing user interfaces with GWT and Java.
As an advanced Flex developer, I am interested in the differences between GWT and Flex. Certainly, the verbose code required to create the layout for a navigation bar makes Flex more attractive, but advanced Flex developers spend 99% of their time writing actionscript. Since the mxml is ultimately turned into actionscript before compilation, it would seem that the obvious next step by GWT is to produce a descriptive language similar to mxml. Still, the frustration of trying to extend and override basic Flex components often makes me wish we created all components programmatically.
I would also welcome a markup language to supplement Java in GWT. I think I understand where you’re coming from with your Flex app – I recently spent some time working on an enterprise-level WPF application and quickly learned that I would spend 99% of my time writing C# and very little time composing XAML. A good UI framework should strike as much of a balance as possible between markup and procedural code – trying to accomplish everything in one or the other quickly becomes cumbersome.
For GWT UI Development, you can use GWT Designer from Instantiations (http://www.instantiations.com/gwtdesigner/). I have used it for a corporate app. It works well except it made my Eclipse IDE crash several times. However according to their web site support this doesn’t seem to happen to other developers, so it might be my Eclipse distribution.
I believe Google should build a visual UI development tool similar to Flex (or BackBase) because it took two months of coding to get my application done, even with GWT Designer help. They should also provide some kind of commercial support.
After I had the application built, my director suggested I look into Flex as a way to build better UIs, so now I am re-writing my app in Flex as a new prototype.
Thanks, I’ll have to check it out. I think GWT really suffers from the lack of a markup language. Eclipse already makes writing the Java as easy as it can be, but the sheer volume of code that has to written slows down the development process when compared to Flex, OpenLaszlo, or Appcelerator.
There is a “Declarative UI” project in GWT Incubator which should simplify building UI in GWT using some kind of mark-up language.
http://code.google.com/p/google-web-toolkit-incubator/wiki/DeclarativeUi
The problem is that it is not released yet and the release date is unknown.