Programming in Tcl and Tk
Tool Command Language, or Tcl, (pronounced “tickle”) is a simple, interpreted language that is similar, in some respects, to the Bourne shell or Perl. The real benefit of Tcl is that it can be extended as well as embedded in other applications. It is particularly popular when used with the Tk extension, which offers about the simplest interface you could get to program with windows. As an additional benefit, you can run your Tcl/Tk problems without much hassle on both Unix, Windows, and the Macintosh.
By extended, we mean that you can add new commands to the Tcl language, simply by writing a few routines in C. By embedded, we mean that you can link a C program to the Tcl libraries, giving that program full access to the Tcl language. Whereas most Tcl programs are written as scripts and executed by a precompiled Tcl interpreter, you can include the interpreter routines in your own application.
For example, let’s say that you wanted to write a command-driven debugger similar in nature to gdb. The debugger would present a prompt and allow users to enter commands such as step and breakpoint.
If the command syntax for your debugger is simple, you could easily write your own routines in C to read a command and process it. However, this approach becomes more complex when you wish to allow the user to define variables, macros, new functions, and so forth.
Instead of writing these routines from scratch, it is easy to embed a Tcl interpreter into your debugger ...
Get Running Linux, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.