Practical Programming in Tcl & Tk

 in
If you're curious and want to learn more about Tcl or if you just want to become more comfortable with the language, Practical Programming in Tcl & Tk by Brent B. Welch is a book you'll want to read and refer to often.
  • Author: Brent Welch

  • Publisher: Prentice Hall

  • E-mail: sales@prenhall.com

  • URL: http://www.prenhall.com/

  • Price: $42 US

  • ISBN: 0136168302

  • Reviewer: John McLaughlin

If you are a Linux user, you have most likely used a Tcl/Tk application. A large number of the applications under Linux use Tcl/Tk (here after referred to as “Tcl applications”) as the GUI front end. Tcl has become popular under Linux for a variety of reasons: flexibility, ease of use, availability of source code, liberal license policy and the gorgeous look to the Tk widget set. If you're curious and want to learn more about Tcl or if you just want to become more comfortable with the language, Practical Programming in Tcl & Tk by Brent B. Welch is a book you'll want to read and refer to often.

A member of the development team for Tcl at Sun, Mr. Welch is perhaps best known to the Linux community for his work developing EXMH, the best mail reader under Linux (small personal bias inserted). In this 2nd revision of his book, he uses 613 pages to lead the user from the fundamental paradigm of Tcl scripts, to using Tk and writing extensions in C.

The book is divided into seven sections covering Tcl Basics, Advanced Tcl, Tk Basics, Tk Widgets, Tk Details, Tcl and C, and Changes. Each chapter begins first with a short paragraph introducing the subject, followed by detailed discussions, tables and a plethora of examples. A helpful feature of this book is the “Hot Tips” marked in the margins, these indicate something particularly useful, tricky or non-obvious.

The section on the Tcl language pleased me immensely; often books fly through the fundamentals of Tcl in order to get to the more “glamorous” Tk section. Tcl is powerful and rich, but can sometimes be a confusing language especially if you don't fully understand the fundamentals. The author's thorough explanation of the basic constructs and group-substitute-evaluate paradigm of the Tcl language was nicely done and clarified my understanding. Anyone who writes Tcl scripts would benefit from reading the first section a few times.

The sections on Tk widgets clearly explain not only the syntax and use of the widgets, but through the extensive use of examples really drive home how to most effectively use them. The book also discusses techniques on how to solve, in a simple manner, problems that face many Tk programmers (such as having a scroll bar attached to two listboxes).

The sections on the Tcl C API are very well done and excellent reading for anyone who is trying to integrate Tcl into a larger application. Not only does the author give a nice overview of the API from a task perspective; he also provides several tricks. My favorite is Tcl_Invoke a C procedure that allows the invocation of Tcl commands without the overhead of substations that come with Tcl_Eval.

Included with the book is a CD-ROM containing all of the examples from the book and a small browser application to help access and run the examples. Perhaps I am being a bit overly critical, but I was a little disappointed with the included browser application. It would have been nice to include a really glitzy Tcl browser to really show off the strengths of the language. Sadly, the included application, although usable, was a little stark and would certainly not inspire a new user of Tcl to get excited about the language. Also included were a collection of Tcl scripts and extensions from the various FTP sites; again it would have been nice if a few more of them had been unpacked and ready to run off the CD.

Although this book is described as being useful for the beginner, as well as expert Tcl user, it really shines for people with at least a little programming knowledge. In some ways the breadth and detail of the book (not to mention its weight) could be a little intimidating for a newcomer. For the true beginner I still like John Ousterhout's Tcl and the Tk Toolkit (although it's getting a bit dated).

Throughout the book the author pulls no punches. Covering the language in great detail and providing many useful tricks, he is equally quick to point out potential pitfalls, inefficient commands and constructs that although legal “probably aren't a good idea”.

A great amount of attention is spent throughout the book delineating features that apply to a specific release of Tcl or a specific computer platform (Unix, Windows, Mac). This is particularly helpful if you are interested in writing truly cross-platform scripts. Whenever possible, attention is given to writing code that will work across multiple platforms and revisions of Tcl. Because the author is part of the design team at Sun, he was able to cover some of the new features introduced in Tcl 8.0 including namespaces, binary string support and the on-the-fly compiler.

Without a doubt this book lives up to its name. It provides an extremely practical view of Tcl and Tk, pointing out its features and flaws while focusing on writing scripts that “get the job done.” Mr. Welch has written a book that is essential reading and reference material for anyone who writes Tcl code or integrates it into a larger application.

John McLaughlin is a project manager at Hewlett Packard working on test equipment for wireless chipsets. A Linux user since 0.99.13, he lives in the San Francisco Bay area with his wife Noel and enjoys traveling, diving, skiing, hacking with Tcl and writing EXMH extensions (under Linux of course). He can be reached at johnmcl@sr.hp.com.

______________________

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix