I've been forced to code in Tcl a number of times, and just can't wrap my head around this language.
It's not just that it is syntactically different than c-like languages: Lisp is different but genius, prolog is different with a valid cause. Tcl is different because it was a bad idea taken to its fullest possible extension.
"Lets make a language where the operator is on the left, just like a shell. When that runs out of gas we'll extend it a hair by letting you have sub-commands in square brackets. And when people notice that it is odd that there are no binary operators we'll extended it by nailing a different language onto it." (The expr
syntax is not tcl, it is c-like.)
Yet it survives, especially in the embedded space. Perhaps because it has a small footprint. But there must be a dozen languages with a small footprint that are easier to code in. Is there some magic goodness I have just missed?
Here is a small Tcl example to refresh you on Tcl. Notice for instance the need for a $
before a variable when reading from it but not writing to it. How did every single other language manage to work that out without needing a hint from the programmer!? Recall that it would be a syntax error to omit the space between the while
and the {
because the parser itself is written in four lines of Tcl and can't deal with crazy stuff like that. Notice that an idea as simple as p--
takes a whole 8 tokens.
proc power {base p} {
set result 1
while {$p > 0} {
set result [expr $result * $base]
set p [expr $p - 1]
}
return $result
}