The Tcl Programming Language: A Comprehensive Guide (2nd Edition)
104 comments
·April 4, 2025gricardo99
neilv
I was leading a Tcl project around then, and, though there were some very neat things about the unusual Tcl evaluation model, I wasn't a fan of using it for nontrival work. For example, it wasn't a natural fit for working with graph structures like I had to, and like you might want for browser DOM.
(That said, Tcl would've been much better than JS, and I suspect that Ousterhout would've figured out some smart things to make it good for the browser.)
Maybe 5 years later, I was meeting with Tim-Berners Lee, and I kinda pitched Scheme to him, without planning to, but he was very interested when he asked what I'd been working on.
But then he went and did a conference keynote, in which he promoted Python as the language for ordinary people doing Web stuff. And I think he referenced one of the things I'd written in support of Scheme... as an anti-requirement for his populist vision for the Web. :)
(I wish I could've been involved in that, because I could've made a case for a populist spin on Scheme at the time.)
no_wizard
Why does JavaScript get some much hate?
TCL has an extremely loose runtime model, not to mention everything in the language is basically a string and all that entails.
I’ve been using JavaScript since the early 2000s, just before ES5 dropped.
Like all languages it has its curveballs but it really isn’t all that bad. It simply has oddities due to the quirky nature of the niche it was designed to fill (namely, to be a scripting language that was forgiving to web designers)
derriz
"Why does JavaScript get some much hate?"
I don't get it either? I've only used it occasionally but it has always struck me as a really impressive example of what can be built on minimal (minimalist?) foundations. Its semantics can understood in 5 minutes.
It reminds me of Scheme in this regard. Writing an interpreter or compiler for it would be easily within reach of an undergraduate student. Contrast with other currently popular (more respected?) languages like Rust, C++, Java, C# or even Python.
I've only recently been expose to Typescript and again, I'm really impressed. I haven't encountered a type system so elegant and orthogonal since first being exposed to ML like languages.
graemep
> not to mention everything in the language is basically a string and all that entail
I disagree with that to at least some extent. Everything is a string works well in TCL because the language is built around that abstraction. It works at least as well as other dynamically typed languages in small projects, and is definitely preferable to Javascript's rather weird weak typing.
It also does async and multi-threading really nicely, and encouraged event driven long before it look off elsewhere.
tgv
I used Tcl briefly to build an interface way back with Tcl/Tk, and it is a terrible language. "Everything is a string" is not what you want in a solid programming environment for larger projects. It's a LISP-like gimmick, but without the advantages of LISP.
That said, plain JS is not a good fit for larger projects, either. It really needs TypeScript for that. But it does have some very fast engines.
padjo
In the early days at least part of the problem was marketing. The fact that it’s got Java in the name when it’s actually a very different language to Java confused a lot of people. They tried to use the language like Java, had a bad time and concluded the language was bad.
lolinder
Honestly? I think the biggest cause of JavaScript hate is that a huge percentage of developers have very little choice but to use it.
The web ate almost everything else for a host of reasons, and JavaScript is still the only language that the web natively supports. You can compile to JS or use WASM with occasional callouts to JS, but you can't get away from it entirely.
Most other languages have a greater sense of choice surrounding them. For backend work you can pick pretty much anything, and mobile is still a small enough chunk of the ecosystem that if you really hate Swift you can just find a job that isn't iOS dev. It's not so easy to get out of web dev without dramatically shrinking your job pool.
otterley
This is a classic: https://www.destroyallsoftware.com/talks/wat
neilv
"Brooklyn Nine-Nine" said it: https://www.youtube.com/watch?v=H1-GDlzODzc&t=27s
eadmund
[flagged]
shanemhansen
I think Tcl as it was back then especially would have been a terrible DOM manipulation choice. I love the language but the hacks frameworks like openacs used to use to imitate basic stuff like a list of database records are among the ugliest upvar/up level hacks I've seen.
But that being said it's an incredibly adaptable language and I have zero doubt it could have been adapted to make DOM manipulation ergonomic.
shanemhansen
If I remember correctly early HTML specs actually used Tcl as an example for script tag content.
It was definitely possible that Tcl could have ended up the web sripting language.
hresvelgr
> It would have been a far better language.
I like Tcl and I think it has some very admirable traits. That being said, I don't even want to picture the hellscape of an ecosystem that would have flourished if it became the language of the web. JS was the better timeline I will admit begrudgingly, and that includes the Scheme timeline as well.
tempodox
Does Tcl have lexical scoping yet? If not, I'd have to disagree that it would have been a better language. JS is not one of the better languages I know, but it does have lambdas and lexical scoping. And as bad as JS's type system may be, at least it's not stringly-typed.
mdaniel
Allow me to introduce you to upvar https://www.tcl-lang.org/man/tcl9.0/TclCmd/upvar.html and its uplevel friend https://www.tcl-lang.org/man/tcl9.0/TclCmd/uplevel.html
I cannot possibly imagine the horrors of frontend frameworks that can grab values, or execute, in someone else's context willy nilly
tempodox
Exactly, it's dynamic scoping. As far as I know, Tcl is the only language that still has this skeleton in its closet.
cmacleod4
With great power comes great responsibility :-)
buescher
In that world, Netscape might have also acquired Naviserver instead of AOL. Wasn't the plan at Netscape to make money on their server software?
smj-edison
Funny that Tcl was mentioned today. I've recently been hacking on jimtcl[1] (a small footprint implementation of Tcl) to make objects multi-threaded safe, as that's the core language that folk.computer[2] uses (the main authors are making the interpreter and reactive DB parallelizable rn, so I've been tinkering with how to reduce copying).
[1] https://github.com/msteveb/jimtcl [2] https://folk.computer/
dvektor
Surprised no mentions of sqlite yet :) I've always associated Tcl with sqlite because of how much it is used in their test suite and how you can have a tcl interpreter as a virtual table. Very interesting and seemingly often overlooked little language.
graemep
I have used both TCL and Sqlite a fair bit but not both together. I have thought that TCL + in memory Sqlite would make a powerful combination for some tasks but have never actually tried it.
> have a tcl interpreter as a virtual table
Do you mean this: https://sqlite.org/src/file/src/test_tclvar.c ?
oldlaptop
I can't comment on virtual-table shenanigans, but I'll enthusiastically confirm that thought. Not only is an in-memory database powerful and useful for all the obvious reasons, but (I would argue) the Tcl interface to SQLite is perhaps the best relational database API in any language. (Even if it cheats a bit by being an embedded database, as with <https://sqlite.org/tclsqlite.html#function>.) It's easily as synergistic a combination as Tcl and Tk themseves, possibly more.
mdaniel
> Some content has been removed in the second edition of the book because of limits on the number of pages
Lol, wut? The literal only working "buy it now" link is to a PDF. Page limits my ass. Or maybe "Paperback: 660 pages" was dangerously close to the Devil himself springing forth from the pages and turning all your codebase into VBScript
usr1106
I have known about Tcl since the 1990s. I remember Stallman advising not use it. Maybe he did not like the license?
Yesterday, over 30 years later I was forced to write my first code. Noticed that a Cisco switch had an incredibly bad ssh implemtation, so to automate some commands I needed expect scripting. Expect is based on Tcl.
dwheeler
Per http://vanderburg.org/old_pages/Tcl/war/0000.html
Stallman's argument at the time was:
"a language for extensions should... be a real programming language, designed for writing and maintaining substantial programs...
The first Emacs used a string-processing language, TECO, which was inadequate. We made it serve, but it kept getting in our way. It made maintenance harder, and it made extensions harder to write...
Tcl was not designed to be a serious programming language. It was designed to be a "scripting language", on the assumption that a "scripting language" need not try to be a real programming language. So Tcl doesn't have the capabilities of one. It lacks arrays; it lacks structures from which you can make linked lists. It fakes having numbers, which works, but has to be slow. Tcl is ok for writing small programs, but when you push it beyond that, it becomes insufficient.
Tcl has a peculiar syntax that appeals to hackers because of its simplicity. But Tcl syntax seems strange to most users."
Treblemaker
> It fakes having numbers, which works, but has to be slow.
This hasn't been the case for 25 years, since the 8.0 release. Tcl will store data internally in whatever format it was last used, and only convert if needed. Good coding practice pays attention to this to avoid "shimmering" a value back and forth between different internal representations unnecessesarily.
> It lacks arrays;
It does have associative arrays; and lists when used appropriately can fulfil many roles that would otherwise have been implemented in an array in another language
And tcllib[0], a collection of utilities commonly used with tcl, provides support for a number of different and complex data structions [1], many of which are written in C, not just more tcl scripts.
It's worth noting that Stallman's criticism linked above is more than three decades out of date. As with any programming tool, once you go beyond a superficial understanding of basic syntax, it can serve as a a very expressive and sufficient language.
[0] <https://www.tcl-lang.org/software/tcllib>
[1] <https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/toc.m...> (see: Data structures)
7thaccount
If I recall correctly, I think he was just more of a lisp fan and promoted something like Guile or E-Lisp. It may have been license as well. I'm not very sure about it though.
bch
I think he was worried about Sun Microsystems involvement[0] w Tcl when John Ousterhout went there[1], too. But mostly seems like a collection of unsolicited strawmen[2]. Also probably love-of-lisp.
[0] That any proximity to commerce is evil?
bc569a80a344f9c
Most IOS implementations (classic, XE, XR) also have tclsh, a tcl REPL (that can also interact with the file systems to load and write scripts).
7thaccount
I own the first edition of this book and it's really good. I've written a few tcl scripts with it, but nothing major. Python just has the better ecosystem now for my needs. I might use tcl if I needed something really small though.
jim_lawless
A TCL interpreter is packaged with Python in the tkinter library:
import tkinter
tcl=tkinter.Tcl()
tcl.eval('puts "Hello, world!"')
7thaccount
I'm aware, but that kind of defeats the point (at least to me). If I want to build out some cute DSL for a project, it would just be with the small tcl interpreter.
pjmlp
Nice memories of having our own AOLServer like clone, Vignette, routinely writing extensions in C, and also why since 2003 I tend to avoid languages without JIT/AOT unless it is for banal OS and application scripting task.
at_a_remove
I may have to learn its other half, Tk, as a side project of mine is starting to feel less like something I can pull off as a "wizard" on the command line. I had wrestled with wxPython many moons ago and, while I got through it, I felt like I had perhaps taken a wrong turn.
As a side note, while I have seen many UI elements over the decades, I cannot help but think that the wizard (or whatever you would like to call it) has somehow escaped being listed as a standard UI element. Perhaps it is too large to count for many.
WillAdams
There is a source release at:
https://www.tcl-lang.com/software/tcltk/9.0.html
but I'm not seeing an easy binary download --- used to be that the availability of a pre-compiled version, nicely packaged which would install easily on one's platform of choice made it wonderfully accessible to new users.
Is that not a focus of the project these days?
Falcondor
Looks like binary downloads are on another page and not necessarily made by tcl-lang
WillAdams
From that page:
- Android 8.6.10 https://androwish.org/download/index.html
- Activestate seems to require account creation: https://www.activestate.com/pricing/
- Windows, nightly build of 9.0.2 from 15 February: https://gitlab.com/teclabat/tcltk/-/packages/34837768
- Windows 8.6.7 https://www.irontcl.com/index.html
This looks like the link I was looking for: Windows 9.0.1: https://www.tcl3d.org/bawt/download.html#tclpure which links to: https://www.tcl3d.org/bawt/download/Tcl-BI/SetupTcl-BI-9.0.1...
bch
I was going to say releases are published to Sorceforge[0] but indeed those look to be all src too. That said: I’d be surprised to find a distro that doesn’t have Tcl available in whatever package manager(s) they support.
WillAdams
Managed to find two Windows binaries as noted elsethread.
It would be nice to have found one for the Mac....
EdwardCoffin
Homebrew has it
VWWHFSfQ
> this immensely flexible and versatile language
I would be interested to know if anyone ever built anything non-trivial that didn't turn into a complete mess due to TCL's general type-flimsyness and "everything is a string" philosophy.
bch
Cisco iOS[0], F5 iRules[1], Tealeaf network monitoring/processing[2][3], Fidessa[4][5], …
[0] https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/ios_tcl/co...
[1] https://community.f5.com/kb/technicalarticles/irules-concept...
[2] https://www.acoustic.com/tealeaf
[3] https://help.goacoustic.com/hc/en-us/articles/360043279654-C...
[4] https://www.cmegroup.com/solutions/market-tech-and-data-serv...
[5] http://www.services.fidessa.com/brochures/_training/VF043.pd...
timewizard
TCL stands for "tool command language." In terms of non trivial tools that have been built with it there have been several. AOLServer, MacPorts, tons of CAD and engineering software. There's a whole wikipedia category just for this:
https://en.wikipedia.org/wiki/Category:Free_software_program...
Aside from that there was Tk which was used to create many UIs in an era where scripted UIs were otherwise painful to create and maintain. A prominent example here is 'xconfig' from the linux kernel.
Like any good environment a little bit of practice with it can see you overcome it's apparent shortcomings and see you producing reliable and useful software in far less time that you might have in a more traditional way.
Programming is about trade offs. It's not a checklist of "good ideas."
wildzzz
My big project at work uses pytk only because it was already included with the anaconda distribution. It works fine, it's not pretty but it's just an internal engineering tool.
sigzero
It's Tcl now not TCL. No longer an acronym. It hasn't been TCL for years.
spacechild1
The GUI of Pure Data (https://en.m.wikipedia.org/wiki/Pure_Data) is written in Tcl/Tk. In the 90s this was a popular and sensible choice, but not so much in 2025 :) I still have hopes that one day we'll manage to replace it with something better.
(There are alternative implementations of Pd, such as PurrData or PlugData, that use different UI frameworks.)
bsder
> In the 90s this was a popular and sensible choice, but not so much in 2025 :)
Infuriatingly, Tcl/Tk (and other things which use Tk) is still light years easier for doing basic GUI programming than anything that exists in 2025.
How the hell can decades have elapsed and Tcl/Tk, Hypercard and VB6 are still vastly better for GUI development than anything we currently have?
dlachausse
In the same vein, Lazarus/FreePascal is an excellent open source and cross platform Delphi clone.
Karrot_Kream
Yes, both Tcl/Tk and Python/Tk are great in 2025 for doing simple GUI programming and this fact does make me sad. Or perhaps we've found the global minimum? Who knows.
spacechild1
git-gui and gitk are also written in Tcl/Tk.
AdieuToLogic
>> this immensely flexible and versatile language
> I would be interested to know if anyone ever built anything non-trivial that didn't turn into a complete mess due to TCL's general type-flimsyness and "everything is a string" philosophy.
Both MacPorts CLI client[0] and ports tree[0] have used it successfully for many years.
Regarding:
"everything is a string" philosophy
That can be said for the vast majority of Unix-like OS user-space programs.davidw
Flightaware, at one point, had a lot of Tcl code
benburwell
This is still very much the case. Although most new code is written in other languages, Tcl still has a substantial presence.
ZeWaka
TCL/tk is used for the vast majority of integrated circuit verification tools. This is used by all the large manufacturers, even competitors use each others tools.
Absolutely huge codebases, there's git blames that go back to the 80s.
buescher
Someone did a nice job of porting your revision control data. It would be fascinating to know what the previous systems were - probably svn or cvs, maybe both in chronological order, but before that?
jhayward
For many years every web page at CNN and all web email at AOL was hosted by AOLserver and coded in TCL. It was not a mess.
bigbuppo
I know in the late 90s, early 2000s they were Vignette shop, back when it was a Tcl application. Can only imagine their relief getting to carry over their tcl knowledge while no longer having to suffer with Vignette. I don't think I've ever heard anyone that actually liked Vignette.
jhayward
I don't recall any groups using Vignette at AOL during that time. It may be that one of the acquisitions used it prior to being acquired, but again, I never heard about it.
pjmlp
A whole company, with our in-house version of AOLServer, using Apache and IIS plugins for the Tcl interpreter, running across AIX, HP-UX, Solaris, Windows 2000/NT, Red-Hat Linux, with our own ActiveRecord like approach (a decade before Rails happened), with connectors for Sybase SQLServer, MS SQLServer, Informix, Oracle, DB2, Access, doing code generation from Oracle based ER diagrams, and an IDE written in VB 6.
Which became a business unit from Altitude Software, eventually due to our MSFT partnership level we got access to .NET builds before it was known to the world, as one of the key Portuguese partners, and started to replicate our stack in .NET, based on the learnings from our Tcl based product.
The founders and core devs, from the original startup, eventually left to create their no code/low code platform, based on the learnings from both technology stacks, what they managed to achieve, and what was not done quite right, out of that OutSystems was born, one of the most successful Portuguese IT companies from the last 20 years.
I think using Tcl for that startup on a tiny Lisbon basement back in the late 1990's, turned out quite alright.
synergy20
I had this book, it's well written.
fithisux
Best of the best. Bought it.
My favorite Tcl story is a little side note about how Tcl could have been the language of the web[1]
Too humble Dr. Ousterhout! It would have been a far better language.1 - https://pldb.io/blog/JohnOusterhout.html