3 ms·
From a language design standpoint, Tcl is simple and beautiful. You can read its entire semantics in its rather short man page. It's got the homoiconicity of
by quatrevingts 15y ago
From a language design standpoint, Tcl is simple and beautiful. You can read its entire semantics in its rather short man page. It's got the homoiconicity of Lisp (with strings instead of lists) which enables very flexible syntax extension. Its simplicity also allows it to be embedded rather easily.
Unfortunately, it's too simple, in one fundamental way which makes the language very flawed: it does not have closures. Callbacks (which are fundamental to I/O or GUI work) are executed from a scope which has access to nothing but global variables. As a result, users of the language must either stash everything in globals, or else perform awkward explicit variable substitution, taking care to distinguish between variables to be evaluated in the present context and variables to be evaluated in the callback context and escape them appropriately (like writing a Lisp macro, but this is in every callback.)
And if you want to implement any higher-order functions, say filter by predicate, you have a problem because you want to pass an argument to the predicate, but you also want the predicate to have access to variables in the scope where it was defined. The predicate is not a first-class function: it's a block of code that you can eval. In fact, you can eval it anywhere on the call stack. That's right: Tcl gets the job done using functions which evaluate blocks of code in their caller's context. If that sounds scary, good, it is.
- deleted 15y ago[deleted]
- davidw 15y agoIt certainly has warts. But it's not bad for something from the late 80ies (my guess is that Tcl is older than a small but significant number of this site's users), and I don't think language design is a key component in being popular / having a healthy community. Exhibits A and B: PHP and Java.
- quatrevingts 15y agoI think Tcl is beautiful example of a certain point in the design space and extremely useful pedagogically. It's not that it has unnecessary deformities (warts) the way that PHP does. Someone could make a much better PHP than PHP by just cleaning up a bunch of nonsense that's only there because its designer didn't know what he was doing. I don't think that's the case with Tcl (or Java, for the most part.) It's just that solving a complex problem with a simple tool can often be more complex than solving it with a complex tool, even if the complex tool requires a bit more up-front learning. Working with Tcl makes it very clear that spending some of your complexity budget on closures pays off big. As far as what makes for a popular language, clearly corporate support is the key factor in some cases, good libraries in others, but I can't really explain the rise of Python except by its design.