3 ms·
I know of Tcl but I don’t know anything about its structure. The number one thing I ask of a language is consistency: the minimal amount of magic and most of t
by gorgoiler 2y ago
I know of Tcl but I don’t know anything about its structure. The number one thing I ask of a language is consistency: the minimal amount of magic and most of the language implemented in itself. Ruby almost got there and then, for me, slipped up on class << self.
How does Tcl fare under these criteria?
- wduquette 2y agoThe Tcl language is made up of commands; a command has a name and takes an argument list, with which it can do literally anything. The standard commands are written in C; Tcl `procs` are commands that are written in Tcl. The control structures, like `if` and `foreach` and `while` is just a Tcl command. The `proc` command that defines a proc is just a Tcl command. I think of it as Lisp for C programmers. So: is the language implemented mostly in itself? No, it's mostly implemented in C. Is there a minimal amount of magic? No; the amount of magic you can do is effectively unlimited.
- bch 2y ago> Is there a minimal amount of magic? No; the amount of magic you can do is effectively unlimited. I might be mistaken, but I think the OP was asking if there is surprising magic (I.e. special cases/considerations) built into the language, in which case I’d say, “No, Tcl is not “magical”, but surprisingly simple and regular.” That said, indeed it’s powerful in its application of its primitives, but you do still need to mind some things (don’t pretend* you can quote better than the quoting engine, don’t pretend* you can do lists better than the list processor, …). Not magical though - very understandable. *rules are meant to be broken, blah, blah, but the “gotchas” are new practitioners falling into this, or advanced cases, falling into this…
- wduquette 2y agoIn that sense, yes, very little magic...enabling vast conjurations. :-)
- robinsonb5 2y agoIt's also absurdly easy to integrate into C or C++ projects, or to write an extension in C or C++ which can be loaded to implement new commands.
- gorgoiler 2y agoThanks for this explanation. It was very helpful. In terms of magic I meant it simply as how big is the set of unchangeable axioms, as opposed to how many things are derived in the language itself from a more minimal set of magical axioms. With Lisp being the language with the least magic lisp for C programmers was insightful!
- wduquette 2y agoAh! Here's the set of axioms: the Tcl Dodekalogue. https://wiki.tcl-lang.org/page/Dodekalogue?R=0&O=Dodecalogue&W= https://wiki.tcl-lang.org/page/Dodekalogue?R=0&O=Dodecalogue...
- gorgoiler 2y agoBrilliant. That wiki is quite something. Getting a real sense of the core of the language is within easy reach.
- sph 2y ago> The Tcl language is made up of commands As someone that is stubbornly trying to design a Smalltalk-Forth hybrid syntax, where everything is words, nay, messages in a declarative/concatenative pipeline, without success, reading this makes me inappropriately giddy. I need to learn Tcl.
- orthoxerox 2y agoTcl is incredibly consistent, because it's homoiconic.
- talideon 2y agoTcl's magic is mainly from uplevel and upvar as they allow you to do crazy stuff with the callstack to enable all kinds of metaprogramming. It's not a lot of magic, but it's very powerful.
- smrtinsert 2y agoIt's a lot of magic. New control structures mean dsls are as easy as thinking about them