Journal Sanity's Journal: SWT and Swing 3
Eclipse has some amazing features, including parsing your code as you type it, and highlighting syntax errors them moment you type them (just like a spell checker). It even suggests corrections for common errors! Quite simply, even if Java was the worst language in the world, Eclipse alone makes a compelling case for using it.
One of the contraversial aspects of Eclipse's design is that it snubs its nose at Swing, Sun's GUI library, and instead they implemented their own, calling it SWT, which people are free to use in their own applications.
Why would IBM do this? Was it simply a case of "not invented here", or was Swing really so flawed that it had to be bypassed completely? This debate it still alive and well in the Java world, but I believe that IBM made the right decision.
When Sun came up with Java their goal was that Java would effectively become the standard layer between the hardware-specific OS and the application layer. Essentially it would no-longer matter whether you were running Windows, Linux, or a Mac, all your Java applications would work, and they would all look the same. As a result, Sun made Swing handle the "look and feel" of Java applications irrespective of what platform they were running on. This was a mistake.
Look and feel is the job of the operating system. This is the way buttons, menus, and dialogs are drawn, what happens when you click them, and other such things. Basically it is the "asthetic" of the user interface. Users expect a consistent look and feel across the applications on their chosen operating system. With Swing, Sun forced l&f into the application layer, where it doesn't belong.
SWT corrects this mistake. When you write an application using SWT it looks like a Windows application on Windows because it uses the operating system to draw the user interface. Similarly, it looks like a Linux application on Linux because it uses GTK, the most widely used Linux GUI library.
Swing tries to do the same by having custom Swing code for each operating system which tries to make it fit in with other applications. By this stage things are really getting silly. Swing tries to emulate the look and feel of the operating system on which it is already running! The notion of so-called cross-platform Java now trying to emulate platform specific features should really tell people that something is very wrong indeed with Swing's design!
SWT has some other advantages too - using tools such as the commercial Excelsior Jet or the free GCJ, it is now possible to compile Java to native code. This removes the onerous requirement to deploy a 14MB Java runtime along with your Java applications. Of course, Sun hates the idea as they are still hanging on to their dream that Java will replace the operating system, but for everyone else it makes Java a viable platform in which to write applications that would otherwise have to be written in C++.
One problem with this is that Swing is so huge that compiling it as part of these applications doesn't make sense. SWT, however, is much more compact, and thus forms the perfect companion to native Java compilers, removing one of the last barriers to Java competing directly with C++ (and about time too!). Take a look at IRate for an example of this in action.
iRate a bad example (Score:2)
Re:iRate a bad example (Score:2)
Re:iRate a bad example (Score:2)