lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Jul 16, 2012, at 8:32 PM, Sam Roberts wrote:

> I've been playing with it. I've had trouble finding a decent tcl
> syntax summary,

"Get used to disappointment."

Tcl is like the platonic essence of a programming language designed around string interpolation, in the same way Lua is for tables and Scheme is for cons cells. A lot of us have written various hacky little macro expansion languages; core Tcl is those done right. Tcl's major charm is that function arguments are not evaluated, making it easy to build special forms and little languages. So other than the core {}[]"$f" syntax, Tcl syntax is whatever you want it to be.

But as the saying goes, "there's no right way to do a wrong thing". Tcl may not be a mess like PHP, but pure and clean doesn't mean particularly ergonomic. Sure, everything is a string, but that's about as cool as everything being a void*; you still have to keep track of how a string should be interpreted. Is it a list? A command? A name of an object? A name of an array? Who's in charge of deleting its referent? You end up with all these second-order memory leaks, since there can be no GC which can know how to interpret strings as pointers.

All-string data structures can accidentally lead to algorithms with performance characterized as "superquadratic". And since everything's a string, Tcl is naturally missing closures, and Tk kinda needed them. Callbacks from UI events were just strings eval'd in the global context, with %x %y printf'd in. 

The language STk was a decent Scheme connected to a patched Tk, and several other languages were maintaining essentially the same Tk patch: give widgets and callbacks a void* and a hook for GC for languages with values richer than strings. IIRC this patch was offered upstream but Osterhout was not interested in making life any easier for people who didn't want Tcl. In today's social environment, Tk would have forked, but that was considered far more rude in that era.

Tcl-the-distribution parted ways with Lua around the time Tcl reimplemented stdio; I think this was around 8.0. I do remember downgrading to Tcl 7.x because it was  significantly smaller when I built http://web.archive.org/web/20000821215129/http://vhl-tools.sourceforge.net/demo1.html . Later versions of Tk depended so heavily on Tcl libraries there was little point in trying to tease them apart.

Tcl did a lot of good in advancing the ideology of using scripting to build applications. It was the Lua of its era. But Lua is the Lua of this era.

Jay