Welcome to Modern Application Development in Tcl/Tk! This book aims to provide a complete introduction to developing applications in Tcl/Tk, and to emphasise modern software development methodology throughout. The book is intended as a free companion and eventual replacement for the existing Tcl Tutorial [5], written by Clif Flynt, Arjen Markus, David N. Welton and Neil Madden. Some material from that tutorial has been reused in this book, but the majority has been heavily edited or rewritten from scratch to reflect current best practices.
Tcl stands for the ‘Tool Command Language’. It was originally developed in the 1980’s by Dr. John Ousterhout, then a Professor of Computer Science at the University of California at Berkeley, as a lightweight embeddable command language for a number of software tools developed by Dr. Ousterhout and his students. The idea was that Tcl would provide some basic facilities common to all programming languages, such as variables, loops, and control structures, and then a host application could embed the language and extend it with new commands relevant to that tool. Users could then use Tcl to control the tool by issuing commands, either interactively or in batch scripts. You can read more about the history of Tcl at http://www.tcl.tk/about/history.html.
Tcl still excels as an embedded command language, but it has also developed into a fully fledged general programming language. The core principles that made it such a good command language: simplicity, extensibility, and ease of integrating different components, have also stood Tcl in good stead as a general purpose language. Today it is used for everything from modern desktop applications, to heavy-duty network servers, and lots in between.
The first part of the book introduces the Tcl language, from basic facilities through to advanced topics such as developing custom flow control constructs and event-based TCP/IP networking. Don’t Panic! No previous knowledge of Tcl/Tk or even programming in general is assumed in this book. Feel free to skip the more advanced chapters to begin with, and then come back to them when you feel more comfortable with the material. The remaining parts of the book introduce a number of popular extensions to Tcl for developing sophisticated applications:
Part II introduces Tk, the Graphical User Interface (GUI) ToolKit, and its newer “themed” companion, Ttk. Together, these extensions allow you to create polished desktop applications that integrate well with all major desktop environments: Microsoft Windows, Mac OS X, and Linux/X11 (KDE and Gnome).
Part III then introduces a number of useful and popular extensions for handling real-world requirements: interfacing to database management systems (Chapter 15), processing XML (Chapter 16), interfacing with Web Services (Chapter 17), and writing powerful Web applications.
This book doesn’t currently cover the implementation of Tcl or how to extend or embed Tcl from C or C++. These advanced topics are covered by the Tcl manual pages and a number of other books on Tcl.
The Tcl community is an exceedingly friendly one. Here are some good places to get help:
The Tcl Developer eXchange (http://www.tcl.tk/) is the main website for Tcl, and contains links to downloads, documentation, mailing lists, and the open source Tcl development project where you can also download the source-code of the Tcl interpreter.
The comp.lang.tcl newsgroup. Accessible via a newsreader, or Google Groups.
The Wiki (http://wiki.tcl.tk/) has a great deal of useful code, examples and discussions of the finer points of Tcl usage.
If you need help right away, there is often someone on the #tcl channel on irc.freenode.net who can help you out, but please don’t be impatient if no one can help you instantly—if you need that level of support, consider hiring a consultant.
There are several other good books on Tcl/Tk if you wish to gain more in-depth knowledge of Tcl. Recommended titles include ‘Tcl/Tk: A Developer’s Guide’[4] and ‘Practical Programming in Tcl/Tk’[12].
The following people have contributed material to this book:
Clif Flynt
Neil Madden
Arjen Markus
David N. Welton