Review of Exploring Expect

Title:
Exploring Expect
Author:
Don Libes
Publisher:
O'Reilly and Associates
Date:
1995
ISBN:
1-56592-090-2
Pages:
566
Price:
$29.95

Reviewed by Nick Christenson, npc@jetcafe.org

April 15, 1998

Expect is an intriguing programming language extension of the Tcl language developed by John Osterhout with others at the University of California at Berkeley. The goal of Expect is to allow the automation of interactive processes on Unix systems. For system administrators many of the capabilities of Expect are truly astounding, and even the most simple scripts can dramatically reduce the amount of time spent doing certain tasks. Exploring Expect, written by the language's creator, is intended to provide an explanation and set of examples for this unusual language which highlight its power and versatility.

By necessity, the book has a little bit of everything in it. The first thing that it does is describe what Expect is and gives some examples of where it might be useful. Some of these early examples are fairly powerful right off the bat, and this is enough information to customize several examples that come in the software distribution. Further, the capabilities of Expect are quite evident, and I'd suspect that the system administrator who wasn't immediately intrigued may not have a very active imagination.

Other information that the book must provide is an introduction to the Tcl language. Since Expect is an extension of Tcl, this is pretty important. While Exploring Expect is no substitute for a book explaining the Tcl language, read Osterhout's Tcl and the Tk Toolkit or Practical Programming in Tcl and Tk by Brent Welch for this information, it does provide enough background for the reader to gain an appreciation of Tcl, and certainly enough information to make meaningful use of Expect. Despite this, I would still recommend that the interested Expect programmer read at least one of these two books on Tcl for a broader understanding of Expect's parent language.

After this, Libes proceeds to introduce the more complex and subtle aspects of the language. We slowly and carefully are introduced to one important concept at a time, and each new idea is accompanied by enough examples to make it understood. The author manages to find a fairly clear path through a very unorthodox language. Despite his best efforts, though, there are places where the order the concepts are presented in seem to be a bit forced, but I doubt there is much more that could have been done to streamline the information any more effectively.

Libes goes into excruciating detail discussing certain key aspects of the Expect language, for example, when discussing how ptys and terminal buffering works, or explaining some common pitfalls when trying to match regular expressions in a data stream. Even though these passages do get tedious after a while, they're certainly necessary. The information they present is vital and will very likely save the programmer hours of frustration. Complex situations usually require complex explanations, and the author has done what he can to minimize the pain and maximize the useful information present.

Nonetheless, there are a few places I would have liked to have seen elaborated on further, most notably, in the chapter on Expectk, the fusion of Expect and another Tcl extension, Tk. I believe the book would have benefited from more examples and, perhaps, a more complete explanation of the capabilities of this combination. Despite reading this book and especially this section carefully, I didn't have all the tools necessary to do most of the things I wanted to do in Expectk. On the other hand, the book is fairly hefty as it is, and I can't strongly fault the decision to not provide a lot more information on, admittedly, more esoteric matters.

Frankly, if one wants to learn Expect one is pretty much forced to acquire this book, as it is the only game in town. While Expect is rarely the preferred long term solution to any problem, it is a very interesting language and suggests some ways to solve quite complex problems in a relatively easy manner. Additionally, those who are interested in this language should count themselves lucky that the only book on this topic is as good as it is.

Capsule:

Expect is a very interesting and unusual language which allows the programmer to implement some remarkably simple and powerful solutions to seemingly complex problems. Exploring Expect is a very good explanation of this language. Even though it does seem to become a bit long at times, these sections are necessary and the author does a very good job of including the vital information. It is fortunate that the only book on this language is a good one.