GUI toolkits: What are your options?

An overview of today's best-bet GUI toolkits

By Cameron Laird and Kathryn Soraiz

March 1998

SunWorld

Abstract

This article provides an overview of the various toolkits (or programming interfaces) available for Solaris. Among these, we selected only the most portable, commercially applicable, and modestly priced packages. The toolkits described here are best for office automation projects, graphical information system (GIS) jobs, GUIfication of legacy programs, system administration utilities that are easy to run, and so on.

We cover the following toolkits: OLIT, XView, TNT, Motif, Java, OpenStep, Tk, MFC, MacOS toolkit, Amulet, GTK, MetaCard, and Qt. You can see how these toolkits compare by checking out our sidebar, Toolkit roundup. (3,000 words)

Have you had your GUI toolkit in for its annual checkup? No? Well, now is a good time to do it. As the wired world moves away from Motif, and toward Java and scripting technologies, you might be better off with a new toolkit. Let's walk through your options together.

What's a toolkit?

Most applications built today fit the windows-icon- menu-pointer (WIMP) model of operations. That is, in our daily work we program things that users point-and-click. The vernacular word for the application programming interfaces (APIs) that manage graphical user interfaces (GUIs) is "toolkit."

While most Unix professionals probably know of only one or two toolkits there are dozens of useful alternatives available. This article will help you learn which of them will best meet your needs. We'll leave the discussion of specialized toolkits designed for three-dimensional or virtual reality displays for another article.

The difficulty in understanding GUI toolkits lies in the number of subtly different concepts involved. When people speak of "Motif," for example, they may have in mind any one of a number of different things:

X: The base for Unix GUIs

First, you'll need to understand the foundation on which most of these toolkits rest. "The X Window System provides the base technology for developing [Unix-oriented] graphical user interfaces," according to a statement from its current custodian, the Open Group. X is a freely-available windowing package, first released as X10.4 in 1986. It provides a consistent API for graphical operations across all Unixes. X has spread in recent years to OpenVMS, Windows, MacOS, and other operating systems. It defines a particular client/server model of operation that segments applications into a display portion and a computational portion. One of the charms of X is that these two portions can run on different machines. This makes it possible to run a weather simulation on the largest supercomputer in the world, yet manage and observe its results from a low-end screen located across the country.

X is not a toolkit, though, at least not for the purpose of this article. X is low level. Most developers insulate themselves from its tedium by using one of the toolkits described below. The important thing to understand about X is where the responsibility for different features lies. For instance, almost all toolkits share font management and screen redirection functionality because they rely on X for these chores. How a menu posts, though, is specific to a particular toolkit.

Most of the toolkits profiled below are APIs layered on top of X. At the same time, several have been implemented over alternative low-level display protocols. Tk programmers write the same scripts whether working on a Macintosh or a SPARCstation. Underneath, the Solaris version of Tk calls X routines, and the Mac Tk invokes MacOS system calls. OpenWin exemplifies another instance of this distinction: It was originally an environment for users and programmers built above Sun's Network Extensible Window System (NEWS). With version 3.3, though, it was rebuilt on top of X.

OpenWindows, SunView, NEWS

In a few Sun-oriented shops around the world, OpenWindows, SunView, or NEWS are the canonical GUIs. OpenWindows -- sometimes called xnews or openwin -- is a windowing environment Sun has distributed as part of its standard bundle since July 1990. Several of the pieces appeared in earlier Sun products as early as 1985. OpenWindows implements Open Look. Open Look is a specification for GUIs that Sun and AT&T published.

SunView was an earlier, proprietary windowing environment, as was Network Extensible Window System (NEWS). Sun continues to support SunView and NEWS in ways too complex to unravel here.

Sun bundled the Open Look Intrinsics Toolkit (OLIT) with OpenWindows. Sun also bundled The NEWS Toolkit (TNT) with most releases of OpenWindows.

XView is Sun's toolkit for X11. Its API is similar to the SunView programmer interface. XView and its sources are free.

The elegance and visual appeal of NEWS and SunView are widely admired. There is no future for them, though. Sun made a strategic decision to keep them proprietary, and they lost to X and Motif. While programmers continue to maintain and occasionally even write Open Look applications, the numbers decline every year.

Motif: The default choice

The single most widely used toolkit in the Unix world is Motif. Motif is the child of a committee. Other Unix vendors feared success for Open Look would benefit Sun disproportionately. Their response was to create the Open Software Foundation (OSF). OSF produced Motif in 1989.

Motif is so ubiquitous that many Unix users confuse it with GUI operations or window managers, or other pieces of technology, and speak as if Motif is the only GUI foundation or toolkit.

Now, the Open Group maintains both X and Motif. With Motif, unlike X, users must pay for their licenses. Most Unix customers don't realize this because such vendors as Sun, Hewlett-Packard, and Silicon Graphics, along with many others, bundle a Motif version with their Unix operating systems. The Motif license fee is simply part of the purchase price for the operating system. Motif remains logically distinct from the OS, though, and third parties sell more recent or otherwise enhanced Motifs for most platforms.

Motif is the market leader among Unix GUI toolkits. As it nears its 10th birthday, it enjoys both the advantages and disadvantages of maturity. It has the most advanced support for text from languages other than English, a wealth of third-party tools support it, and hundreds of books and online documents explain it. It's also mediocre in performance, difficult to program, and a poor fit for modern object-oriented styles.

Why use Motif?

Portability is beginning to have a whole new meaning in Motif programming. Traditionally, one of the attractions of the high-end toolkits from such vendors as Neuron Data and Visual Edge has been that they managed the complexity of working with Motif on different platforms, and sometimes even targeted other low-level toolkits than Motif.

What all these vendors are doing now is targeting Java as an alternative platform to Motif. Customers clamor for this, and it's the correct strategy for the vendors to take. There's a danger in it, though. If customers continue to rely on proprietary power widgets from the vendors, the latter will prosper. Their fear is that customers are using the Java capabilities just as a way to migrate legacy applications away. It will be interesting to see which Motif tool-makers survive the transition to a world that Java dominates.

Java

Sun's default answer to almost all questions these days seems to involve Java in one way or another. This applies in particular to the search for a GUI toolkit, where Sun hopes to see more and more use of the Java APIs.

Writing in Java holds the promise of unparalleled portability. Java applications run not just under Unix, but also Windows, MacOS, and much more. At least, that's the dream. As of spring 1998, it remains more dream than reality. Java should be a big winner as we enter the 21st century. It's likely that the current difficulties in porting are transient. Certainly Java has the features -- re-entrancy, thread safety, and a strong object-oriented model -- that modern techniques require. But Java's toolkits simply aren't mature yet, and they are unavailable or incompatible for several platforms. WIMP appearance varies between Win95 and Solaris, and JavaSoft frequently releases toolkit versions for such popular Unixes as HP-UX and Digital Unix long after the ones for Solaris and Windows NT.

Java supports a family of GUI toolkits. First was the Abstract Windowing Toolkit (AWT). We discourage programming in AWT. AWT is difficult. Although Sun Educational Services and the Sun Java Certification Program emphasize AWT, we find it is simply not a useful toolkit for most programming teams. The one salient advantage of AWT is that third parties sell interesting and useful tools such as JBuilder for AWT programming. If you do pursue AWT, bookstore shelves are heavy with explanations of it.

More useful for day-to-day programming tasks are the Java Foundation Classes (JFC). A key element of Sun's February 1998 1.1 release is the new high-level components, nicknamed Swing or Swing set. These are quite heavy; Sun recommends 32 megabytes of RAM for developers working with Swing. What that weight buys is a rich widget set, accessibility support for the blind or those with other disabilities, drag-and-drop functionality, and a pluggable look and feel. Sun's JavaSoft division also promises that JFC will be the framework for such planned enhancements as multimedia controls and a two-dimensional graphics API.

One interesting twist to all of this is the fact that Eugene O'Neil, a student in Boston, has written a freeware X implementation in Java he calls the X Tool Collection (XTC). His aim is to replace the existing C source code for X. This will yield what O'Neil advertises as a "small, simple, object-oriented, and multithreaded" base for Motif and other toolkit programmers. The irony of this must be particularly poignant for chief Java engineer James Gosling. As mentioned above, NEWS lost out to X a decade ago. Gosling designed NEWS.

OpenStep

One more echo from the '80s deserves mention. NextStep was the development environment for the NeXT cubes. NextStep was renamed OpenStep for its release under HP-UX, Solaris, Windows NT, and other OSs. It inspires wild enthusiasm in its programmers for its power and aesthetics. As with Open Look, its market penetration has disappointed its owners. Now it appears to be in the ascendant again, as part of Apple's latest OS, Rhapsody.

Tk: Scripting GUIs

The toolkit we use most in our consultancy is Tk. Tk is a GUI extension to the Tcl scripting language. It's freely available for MacOS, OpenVMS, OS/2, Unix, Windows, and other OSs.

Thousands of successful applications are written in Tk. Many are quite sophisticated; Tk has firmly established itself in niches of GIS and electronic design automation (EDA). Perhaps an even greater testimony to Tk is the number of other packages that have embedded it, despite religious objections. Popular toolkits give Tk bindings for other languages, including Perl, Python, C, and Scheme. Sunscript, the development team responsible for Tcl and Tk, has one FAQ that begins, "I hate Tcl, but I think Tk is cool."

Perhaps Tk's greatest virtue is its ease of use. It takes only a couple of lines to make a primitive GUI application.

Tk isn't perfect. While it's the most portable toolkit we've encountered, it feels a bit old-fashioned in its poor support for multiple document interfaces (MDI), tabbed folders, and other widgets that end users have come to expect.

Related extensions of Tcl provide toolkits that extend form-based GUIs to character-only terminals.

Qt: Faster and more extensible than Motif

Qt is a shareware toolkit perhaps best known for its role in the K Desktop Environment (KDE). KDE is a freeware project destined to produce a fast and coherent desktop environment for the X Window System.

Even apart from KDE, though, Qt has a lot to offer. It is fundamentally an object-oriented improvement on Motif. It is a multiplatform (Unix X, Win95, and WinNT) C++ GUI application framework that's fully object-oriented, easily extensible, and much faster than Motif for important operations. Its architecture is cleaner than Motif's. Qt is exceptionally well documented and several commercial products already rely on it.

Qt's developer, Troll Tech, explains "Qt provides a signals/slots concept that is a type-safe alternative to callbacks and at the same time allows objects to cooperate without any knowledge of each other. This makes Qt very suitable for true component programming." Another important innovation in Qt's architecture is its abstraction of the display destinations of widget, pixmap, picture, and printer. This simplifies a variety of programming tasks, including animation and printing.

Python and the benefits of scripting

Python is a scripting language, like Tcl or Perl. Python's official release includes the Tkinter toolkit, which binds Tk to Python. Extensions to a dozen other toolkits are also available. Python's clean object-oriented design has facilitated toolkits which provide for scripting MFC, Amulet, Qt, Motif, GTK, AWT, and more. Python is remarkably portable. It's an excellent vehicle with which to learn, prototype, and, in many case, deliver finished applications.

Most other scripting languages support at least one or two of these toolkits. "Scripting" involves a number of technologies and ideas. Most important for GUI programmers is the swiftness with which it's possible to develop applications in scripting languages. Motif and MFC programmers are familiar with the edit-compile-link-debug cycle, where the linking phase alone (of a simple change to adjust a single widget position) can take five minutes. With scripting languages, there's an immediate response to such edits.

MFC: Bringing the Microsoft world to Unix

The next two families of toolkits are of no intrinsic interest to Unix programmers. They offer no advantages over the other toolkits cataloged -- except that they're compatible with existing work on other platforms for which you might be responsible.

Microsoft Foundation Classes (MFC) is the dominant toolkit in the Windows world, followed most closely by Borland's Object Windows Library (OWL). MainWin is one commercial implementation of MFC for Unix. The section on Python, below, also points to an MFC alternative.

Latitude makes Solaris look like a Mac

Metrowerks sells almost all of the MacOS API for Solaris, IRIX, and Rhapsody under the product name, Latitude. We haven't used Latitude. Many readers will be familiar with Metrowerks' acclaimed CodeWarrior, though. Just as the MFC ports most interest those who need to move existing Windows programs to Unix, Latitude most interests developers who reproduce MacOS functionality on Unix desktops.

Amulet animates

"Amulet is an entirely free, public domain user interface development environment in C++. Code written using Amulet will work with little or no changes on all platforms." So says Amulet's FAQ. Amulet has particularly strong support for such operations as undo, gestural recognition, tool tips, and animation. Amulet enables constraint-based programming and an innovative input model it calls "interactors." Amulet descends from a late 1980s LISP project called Garnet.

GTK: GNU project power

GIMP is a freely-available image manipulation utility that duplicates much of PhotoShop's functionality. GIMP ToolKit (GTK) is the small, efficient toolkit used to construct GIMP. GTK is also at the heart of GNOME, a freeware desktop manager for Unix. GTK, in the tradition of other Free Software Foundation projects, has little documentation and a bit of a bias toward Linux. In principal it's portable to Windows and MacOS, but no one has yet done the work to make it so. It's generally more powerful and faster than Motif. Bindings exist for C, C++, Perl, Guile, and Python.

MetaCard is HyperCard for the '90s

MetaCard is a multimedia authoring tool and GUI development environment for Unix/X11 workstations and Microsoft Windows 95 and NT. It inherits much from the HyperCard Apple developed for the Macintosh in the '80s, including a strong position in development of computer-based training applications. MetaCard benefits include its ease of use and portability. A port to MacOS is "our top priority at this point," according to president Scott Raney. Although Raney says that MetaCard hasn't announced a release date for this, the new version is nearly through a complete cycle of alpha-level tests.

Conclusion

Make your toolkit work for you. If you're not a GUI programmer now, know there are plenty of resources to help you start. If you're already working with a toolkit, and it's too expensive, slow, cumbersome, or otherwise limiting, make a change. Try out freeware. Use one of the new high-performance toolkits. Buy a third-party product, or get help through classes or a support contract. (Be sure to see our sidebar, "Toolkit roundup," below.)

Nowadays most of the technologies we've discussed are more or less compatible. You might sit at a Macintosh screen, developing a Windows-style MFC application hosted on a Unix workstation, built with a scripting language. If you know what you need, in 1998 there's a fair chance someone has created it already, or at least enough pieces that you can put it together yourself.

If you've only programmed through an edit-compile-link-debug cycle, you particularly owe it to yourself to experiment with one of the scripting languages that can create small applications in less time than a single compilation sometimes takes. Have fun with your GUI programming!

Resources

Toolkit resources More resources

About the author
Cameron Laird and Kathryn Soraiz manage their own software consultancy, Network Engineered Solutions, from just outside Houston, Texas. They invite you to e-mail them for notice of upcoming articles. Reach Cameron at http://www.sunworld.com/sunworldonline/cgi-bin/swol-mailto.cgi?cameron.laird@sunworld.com+/swol-03-1998/swol-03-gui.html+author.

Last modified: Tuesday, December 15, 1998

Toolkit roundup

Toolkit Market presence Market momentum License fee Technical advantages Technical disadvantages Portable beyond Unix? Scriptable?

Amulet

tiny unclear free animation unusual yes yes

GTK

tiny unclear free speed of performance no docs no yes

Java

medium exploding free Java juvenile yes yes

MacOS toolkit

medium static $399 Mac compatible difficult yes no

MetaCard

tiny growing $995 ease-of-use, computer based training small developer community yes yes

MFC

dominant static $0-1000 Win compatible complex yes yes

Motif

dominant static $0-1000 maturity difficult barely yes

OLIT, XView, TNT

medium steep decline bundled legacy compatible, pretty old no no

OpenStep

niche unclear ~$1000 power, beauty inconsistent platform support yes no

Qt

tiny growing $0-1470 quality long maintenance cycle yes yes

Tk

medium growing free ease-of-use, portable few built-in widgets yes yes

Copyright 1998