Swing and AWT, argh
Posted May 22, 2006 14:50 UTC (Mon) by
lauwenmark (guest, #37754)
In reply to:
Swing and AWT, argh by man_ls
Parent article:
Harmony project to get a Swing/AWT implementation
Sun engineers came up with an utterly stupid solution which solved a
problem that nobody had. The all-Java (or pure Java in Sun parlance)
graphical toolkit was built on top of AWT: with it the interface could
sport a Windows look-and-feel on Solaris and viceversa. Very
useful.
The problem it solved was that the way AWT behaved and looked like
changed a lot between its various implementations. The goal of using
Swing was to provide an abstraction layer that made possible for an
application to display and behave exactly the same on all platforms - a
goal the limited design of AWT was unable to fullfill.
Let's also not forget that Swing provides a MVC model which AWT lacked -
that too was a rather important progress.
In the process they created a slow, highly bloated environment and a
memory hog, which needed endless optimizations to be barely useful. By
the way, all look-and-feels were ugly. This monstrosity was called
Swing.
Given that the current implementations of Swing are able to use
underlying accelerated graphical capabilities (D3D/OpenGL) where
available, the lack of speed Swing had in the past seems hardly relevant
nowadays. Now, maybe you have some benchmarks to back up your facts ?
As for the Look-and-Feels, it is mostly a subjective point - and
nothing prevents you to develop and use your own LnF if you don't like
the provided ones.
So now we are stuck with it forever. In fact, gcj and GNU Classpath
are mostly complete except for AWT and Swing.
AWT and Swing are large libraries with lots of classes to implement. And
they weren't the most needed classes to implement first. Moreover, no
compatibility test suite existed for Swing/AWT, so it is not easy to
guess the correct behavior in all cases.
Meanwhile, IBM (and later the Eclipse project) found the time to build
a much lighter and faster environment, called Standard Widget Toolkit or
SWT. It uses the novel (yeah, right) idea of using platform-specific code
internally to display controls, and still presenting a uniform API. It's
good stuff. The bad news is: even if you only want to use SWT
applications, you still have to carry the burden of Swing.
Other bad news related to SWT: only the Windows implementation is decent
performance-wise; the documentation is far from the level of what's
available on Swing; SWT programming requires manual ressource-management;
portability is inferior, some features not being available on all
supported platforms.
Underlining the deficiencies of Swing is one thing - but next time, try
not to forget to also underline those of SWT to compare both.
(
Log in to post comments)