In The Art of Unix Programming , Eric S. Raymond , presented a critique of Tcl. This page presents an excerpt from the printed edition containing the critique, followed by a response to it. This excerpt has been slightly updated in the online version of the book.
Tcl (Tool Command Language) was designed for writing small programs and embedded scripts (that is, scripts called from within C programs and returning values to those programs). Tcl has become popular not so much for itself as for several facilities that have been built on top of it. The two most important of these are:
The Tk toolkit is so important that the language is often referred to as Tcl/Tk. (However, the Tk toolkit has a semi-separate life of its own, and is also frequently used with Perl and Python.)
The main advantage of Tcl itself is that it is extremely flexible and radically simple. The syntax is very odd but totally consistent. There are no reserved words, and is no syntactic distinction between a function call and ``built-in'' syntax; thus the Tcl language interpreter itself can be effectively redefined from within Tcl (which is what makes projects like Expect reasonable).
The main drawback of Tcl is that it has only weak facilities for namespace control and modularity, and one of those (upvar) is rather dangerous if not used with great caution. It scales up very poorly -- it is hard to organize and debug Tcl programs of even moderate size (more than a few hundred lines) without tripping over your own feet. The oddities of the syntax can be a problem as well; the distinction between string quotes and braces will probably give you headaches for a while, and the rules for when things need to be quoted or braced are a bit tricky.
TCL also cannot handle I/O to binary files at all, and only provides access to a relatively small commonly-used part of the Unix API (essentially just file handling, process-spawning, and sockets). Indeed, Tcl has the flavor of an experiment in seeing how small a scripting language can get and still be useful.
The definitive Tcl reference is [JO]. The Tcl world doesn't have one central repository run by a core group analogous to Perl's or Python's, but there are several excellent websites that point to each other and cover most Tcl tool and extension development, including http://purl.org/tcl/home/ , http://purl.org/tcl/wiki/ , and http://www.purl.org/NET/Tcl-FAQ/ .
Tcl implementations exist for Windows 95 and Windows NT. Tcl/Tk scripts will run cross-platform with GUI capabilities.
Case Study: TkMan
TkMan is a browser for Unix man pages and Texinfo documents. At roughly 1200 lines, it is quite large to be written in pure Tcl, but the code is unusually well-modularized and mature. It uses Tk to provide a GUI interface quite a bit nicer than either the stock man(1) or xman(1) utilities support.
TkMan makes a good case study because it exhibits almost the full gamut of Tcl techniques. Highlights include Tk integration, scripted control of other Unix applications (such as the Glimpse search engine), and the use of Tcl to parse Texinfo markup.
Any of the other languages would have made for a less direct interface to the Tk GUI that constitutes most of this code.
A Web search for “TkMan” should turn up sources and documentation.
Moodss: A Large Tcl Case Study
The Moodss system is a graphical monitoring application for system administrators. It can watch logs and gather statistics for MySQL, Linux, SNMP networks, and Apache, and presents a digested view of them through spreadsheet-like GUI panels called ‘dashboards’. Monitoring modules can be written in Python or Perl as well as Tcl. The code is polished, mature, and considered an exemplar in the Tcl community. There is a project website.
The Moodss core consists of about 18,000 lines of Tcl. It uses several Tcl extensions including a custom object system; the Moodss author admits that without these “writing such a big application would not have been possible”.
Again, any of the other languages would have made for a less direct interface to the Tk GUI that constitutes most of this code.
Trends for the Future
Tcl has been in a period of relative decline, or at least of diminishing visibility. New Tcl releases since 8.0 have added little to its capabilities. In 1996 a widely-reported and plausible estimate of community sizes held that for every Python hacker there were five Tcl hackers and twelve Perl hackers. Today, judging by search results at SourceForge, Tcl and Python have switched places.
As the above indicates, Python has risen in popularity as rapidly as Tcl has fallen. Though the Perl community is still quite a bit larger than Python's, a visible tendency of the brightest Perl hackers to migrate to Python has been rather ominous for the former language -- especially as there is no migration at all in the opposite direction.
namespace provides reasonable facilities for namespace control, and the other provides no details other than his opinion as to what he found lacking.
Again, no details other than the author's opinion. Various large projects have been written in Tcl.
upvar, is a powerful tool that, used in a skilled way, makes many things possible, without being unwieldy.
The problems people have with Tcl Syntax invariable arise from expectations gained through experience with other languages. Very few languages has such clear, minimal, and consistent syntax rules as Tcl.
Whatever the state of previous versions of Tcl was, modern Tcl handles binary I/O perfectly fine.
Tcl is a portable programming platform. Packages like TclX can be used where OS-specific facilities are needed. The core of Tcl aims to be small, with additional functionality made available through modular packages.
embedded usage of tcl ( the invisible tcl )