John Ousterhout describes his Tool Command Language (Tcl) library as an "embeddable command language". I think of it as an "extensible shell" or perhaps an "application backplane". Whichever description you choose, Tcl is a really nifty programming hack, and it's free.

Tcl-based applications share a common command language containing over two dozen built-in commands. These commands handle control flow, expression evaluation, and so forth, providing the basic functions of a typical shell. The application adds its own commands to the mix, and voila, a specialized shell is born.

But that's only part of the story. John has used Tcl as the basis for Tk, a script-driven X11 toolkit. Tk is also written as a library, so C programmers can use it (in addition to Tcl) as the basis for windowing applications. Used in this mode, Tcl and Tk provide a pleasant, abstract alternative to the normal X11 libraries. Tk hides low-level details, allowing programmers to work efficiently.

Tk's interpretive scripting language allows programmers to extend applications at run-time. Scripters should check out the Tk-based windowing shell (wish). Like USL's Windowing Korn Shell, wish allows application programmers to develop simple window-based applications with very few lines of code. The interpretive execution encourages experimentation and speeds development.

It should be interesting to watch WKSH, wish, and other script-based windowing languages compete for UNIX programmers' interest. WKSH is part of SVR4.2, so it will be widely available in the near future. Many ksh programmers will find it a convenient and familiar tool. The competitors are freeware, however, and may be able to provide features and flexibility that WKSH cannot.

Tk has a novel and powerful facility for linking applications. The Tk send command allows Tk-based applications to exchange arbitrary Tcl commands. These commands can retrieve or update data, trigger actions, etc. In short, they can perform any function available to the applications' user.

John would like send to form the basis for networks of cooperating interactive utilities. I see this as a possibility, but I'd like to see more structure in the message protocol. Given complete access to an application's source code, a Tcl hacker can make it react properly to external commands. This could be a lot of work, however, and mistakes are quite possible. Worse, there is no guarantee that another hacker isn't making different, incompatible modifications at another site. In short, although the basic technique is very powerful, the software engineering aspects make me nervous.

Where is it?

Current Tcl and Tk distributions are available for FTP from ftp://ftp.cs.berkeley.edu/ucb/tcl/". The Tk distribution (e.g., tk3.0.tar.Z) is the best starting point; it contains source code for Tcl, Tk, and wish, along with USENIX papers on Tcl and Tk.

You should also pick up John's wonderful book:

    An Introduction to Tcl and Tk
    John K. Ousterhout
    Addison-Wesley, 1993
  

Don Libes has written an interesting and useful Tcl application that allows interactive programs to be run in batch mode ("expect: Curing Those Uncontrollable Fits of Interaction", USENIX Proceedings, Summer, 1990). You can get expect from ftp://durer.cme.nist.gov/pub/expect/. If your program requires terminal emulation as well, pick up expecTerm from Barkley.

Resources

The Tcl and Tk documentation is really quite substantial, considering the fairly early state of development. The (Tcl and Tk) USENIX papers are a good place to start. If you have the March issue of SunExpert Magazine, look at (shameless plug warning) my other column, I/Opener. It is an overview and tutorial on Tcl and Tk programming.

I also recommend printing out Dr. Ousterhout's book draft. It is substantial (around 130 pages), so it takes a while to print, but it will help you survive until the real thing becomes available. Like the rest of his writing, the draft is clean, organized, and easy to understand. I'm confident the book will have the same high quality.

If you get really interested, consider joining the Usenet group comp.lang.tcl. Dr. Ousterhout (ouster@cs.berkeley.edu) also welcomes comments, but he is very busy, so be sure to RTFM before you bother him...

Futures

Tcl and Tk are under active development; don't expect the interfaces to remain the same forever. In fact, expect substantial changes. For the moment, Dr. Ousterhout is more concerned with improving the design than with keeping things compatible for current users. He has promised, however, to "batch" his incompatible changes, giving us periods of relative stability between major releases. Makes sense to me, and to the growing legions of Tcl experimenters...