Tcl Programming Language: 20 Things You Don't Know
Tcl Programming Language: 20 Things You Don't Know
by Darryl K. Taft
Tcl is a scripting language created by John Ousterhout. The Tcl programming language was created in the spring of 1988 by Ousterhout while working at the University of California, Berkeley. It was originally "born out of frustration."
The combination of Tcl and the Tk GUI toolkit is referred to as Tcl/Tk, which is often pronounced "tickle tock."
ActiveState says there are 500,000 developers of Tcl/Tk overall and 80,000 in their ActiveTcl community.
ActiveTcl was first released in 2001. ActiveTcl is ActiveStates implementation of Tcl.
Tcl philosophy centers on one idea: It's an extendable language. Most languages allow a developer to write functions and procedures, but Tcl goes further. Tcl allows developers to extend the entire language with new commands and functionality, including adding fundamental language structures such as object orientation. The Tk toolkit is another optional extension to the Tcl language, which provides a whole set of Tcl commands to create, drive and control GUI widgets. Like other extensions, Tk has long been included in the Tcl core distribution and now is more a part of the language than an extension of it.
Easy to Learn
Tcl is perhaps the simplest syntactically, having only 13 rules. Free online resources and a number of Tcl books are available. The core Tcl documentation itself is often enough for novices to get started, and non-programmers such as system/network administrators can use it.
Tcl apps run on Windows, Linux, Mac OS X, and almost any Unix variant, including Solaris, HP-UX, AIX. Additionally, it has been ported to a variety of embedded operating systems (Windows CE, QNX, VxWorks).
Unlike other languages that have changed drastically over time—causing upgrade headaches for those deploying them—Tcl has maintained excellent backwards compatibility. With few exceptions, 10- to 15-year-old Tcl code runs unmodified in the latest version.
The Tcl language has been evolving since its creation in the late 1980s. As with other open-source languages, Tcls codebase is under constant scrutiny and benefits from having many eyes on the code.
In November 2009, the current version of Tcl was released, Tcl/Tk 8.5.8. In October 2010, ActiveState released ActiveTcl 8.6 Beta 4. Later in 2011, ActiveTcl 8.6 will be ready for production use in enterprises.
• All operations are commands, including language structures. They are written in prefix notation.• Commands are commonly variadic.• Everything can be dynamically redefined and overridden.• All data types can be manipulated as strings, including code.• Event-driven interface to sockets and files. Time-based and user-defined events are also possible.• Variable visibility restricted to lexical (static) scope by default, but uplevel and upvar allowing procs to interact with the enclosing functions' scopes.• All commands defined by Tcl itself generate error messages on incorrect usage.• Extensible, via C, C++, Java, and Tcl.• Interpreted language using bytecode • Full Unicode (3.1) support, first released 1999.• Platform independent: Win32, UNIX, Linux, Mac, etc.• Close integration with windowing (GUI) interface Tk.
Expect is a Unix automation and testing tool, written by Don Libes as an extension to the Tcl scripting language for interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, ssh, and others.• Scripting remote command-line applications is difficult, but using the Expect package in Tcl makes these interactions easy to "drive" remote command line applications, or automate existing or legacy tools that were never built to be automated.• Expect programs written in Tcl are the easiest way to "drive" remote command line applications.
Enterprise Uses of Tcl
• Test Automation—Tcl and Expect are well suited for automated testing as Tcl scripting helps QA teams test much more efficiently and thoroughly• Test automation, and network equipment products from companies such as Cisco, Ixia, Agilent, Fanfare, Spirent, Conformiq, and Wind River all support use of Tcl or require Tcl to run• Companies such as f5 (iRules) and Nortel (Bay Command Console) use re-branded versions of Tcl in many of their devices.
In 2006, Cisco added Tcl to the Cisco IOS, significantly raising the profile of Tcl and added robust end-user documentation. The Cisco IOS Tcl shell is now standard on many Cisco routers. Cisco book released June 9, 2010: Tcl scripting for Cisco IOS.
• "Normal"- Test automation- GUI creation- Embedded functional language• Creative- Powers the Mars Rover- Armies in Lord of Rings movies animated by Massive Softwares crowd simulation tool where Tcl is used to automate large repetitive tasks
Tcl with Batteries
There is a a large corpus of add-on modules. Tcl has a number of networking libraries that can be used to directly access network protocols such as DNS, FTP, NTP, SMTP, HTTP and SSL.
Thousands of active Tcl developers worldwide have contributed to a vibrant community. Many online resources are available for sharing scripts and advice.
ActiveTcl is the commercial-grade distribution of Tcl from ActiveState, and on average, 15,000 people download it every month. Its available for all major platforms and includes popular extensions, the Tcl Package Manager (Teapot) for simpler module management, and complete documentation. There also is a Community Edition free for developers, and Business, Enterprise, OEM editions for business and mission-critical applications. There also is a Tcl developer kit.
Teapot and Teacup
Teapot is a Tcl repository and Teacup is a Tcl client.
Resources for the language include Tcl Developer Xchange (hosted by ActiveState), Tcl Wiki, Tcl Tutorial, and Cisco IOS hints and tricks blog. Recommended books include Tcl and the Tk Toolkit, 2nd Ed, and Practical Programming in Tcl and Tk, 4th Ed.