« Groovy can give Swing a fresh start | Main | Groovy SwingBuilder and Bindings, a Hole to be Filled. »

Swing Can Find Salvation in Groovy

With all of this talk about saving Swing, perhaps we missed the connotation it should be taken in. Saved as in "being born again" or a transcending [linguistic] experience. Perhaps we have strayed away from the notion of people running around with their Bibles shouting at each other something to the effect of "My religion is better than yours." Since that was basically what happened to the Swing vs. SWT dialog I can see how we would all put up our mental blinders.

But the implication I like from the "Saved" is the part about trancendance, I mean that in and of it self sounds kinda groovy. A dynamic language can open up a whole new plane of understanding to swing that wasn't available in static languages. But along with any other change sometimes it has a cost. The problem with religion, is that generally speaking they require an exercise of faith, with doesn't really address the concerns of doubt, it (for lack of several paragraphs) ignores it most of the time.

For example, there are some things that a dynamically typed language, by definition, cannot address. One of those is type-safe enumerations. While Groovy can turn on some type safety when explicitly stated, the implementation of the SwingBuilder really cannot guarantee that at compile time. Not only that, but since Groovy 1.0 runs on a 1.4 era JVM, it cannot reliably use the typesafe enums that debuted in Java 5.0.

There are also issues related to swing that will never be related to which toolkit you use. One of those is the concern that it renders slow, even on old hardware. I can tell you from extensive personal experience that if you hammer out all of the work you do in the Event Dispatch Thread you can make your application run just fine on a circa 2001 Dell Laptop with a 900MHz Pentium 4 processor with only 256Mib of Memory. I know because that was the reference machine I did a lot of my GUI work on in a previous life, and I removed almost all of the grey boxing from the GUI at the behest of the QA fascists (very skilled QA fascists if you must ask). And I did most of it with a debugger attached, on a 1.4.2 JVM to boot. But that's the problem with religion: even if you make it easy some people will still go their old ways, oblivious to the sin they commit. Making a Swing GUI spin like a top is truly a labour of love, ask the coders at JetBrains, they can tell you. And it's not restricted to Swing, making a quality GUI is always a matter of attention to detail. what changes between GUI toolkits is which details you have to look at.

Finally, there are some things that getting religious about Groovy can address. One of those is the leakage of package contents from java.awt to javax.swing. For example, how would you use a Grid Layout and a Box Layout in the same panel without importing different packages? Like this:

import groovy.swing.SwingBuilder

frame = new SwingBuilder().frame {
  gridLayout(rows:2)
  label("Code in Groovy?")
  panel {
    boxLayout()
    button("Yes")
    button("Ahhh  Yeahhh!")
  }
}
frame.pack()
frame.show()

Because the Swing Builder is a total replacement for the traditional way of hand assembling the swing frames, we can remove some of the layering issues. There are also a lot of other things that can be done, but it may take a while before the better practices become mainstream.

But that does always seem to be the problem with religions, they can often be separated into two groups: the group the Methodists belong in and then the group Moonies belong in. Religions that got mainstream acceptance and those that didn't. It is still too early to decide if this dynamic language fervor (in general, not just for Swing) will cross the chasm or fall into it.

Comments (1)

rehte:

Swing need no salvation. It is live and well. Who to save you?

Post a comment


About

This page contains a single entry from the blog posted on February 26, 2007 9:21 AM.

The previous post in this blog was Groovy can give Swing a fresh start.

The next post in this blog is Groovy SwingBuilder and Bindings, a Hole to be Filled..

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33