can you elaborate? I always wonder if I should learn it, how it would make me think in new ways and how I would use it. Tcl looks strange and that makes it very interesting for me so how do you use it and why do you use Tcl for it?
The top level of parenthesis-es is left out, the other levels replaced by brackets :). But joking aside, I greatly enjoy both Lisp and Tcl as languages.
A huge, seriously annoying problem with TCL is lack of deterministic cleanup for resources. If you don't manually close a filehandle, for example, it will leak. Doing this sort of bookkeeping in 2015 is infuriating.
This illustrates how you can use Tcl to ensure that files get closed even when errors happen by combining catch, close and return (from the Tcl manual):
proc withOpenFile {filename channelVar script} {
upvar 1 $channelVar chan
set chan [open $filename]
catch {
uplevel 1 $script
} result options
close $chan
return -options $options $result
}
You could easily wrap the middle uplevel in a catch block to handle exceptions, and this sort of "with" construct is pretty common in a lot of very popular languages today.
While it would be nice if this were baked into the language, it's pretty astonishing how extensible Tcl is without even having to touch the realm of C extensions.
I think this precisely one of Tcl's strengths. Few other languages apart from Lisp and Tcl lets you write your own control flow syntax from within the language (and at runtime).
Garbage collecting languages will free memory, but that's all they're good for. C++ destructors will let you close a filehandle, but I know of no other language that will deterministically clean up non-memory resources.
So: What language(s) did you have in mind that do this right?
Lisp for example has unwind-protect, which is guaranteed to run the unwind code when you leave its scope in which way whatever (be it an exception or a return). So this is a reliable way of running clean-up code at the end of a code block.
Not for tcloo objects, channels and file handles. I don't think you get it. In sane languages like C++ you can expect a destructor to call itself no matter where a function exited.
Cool...now I get to play. Perl does it because it goes out of scope once the sub is run. I am pretty sure you can tell TclOO to do the same thing (play time) if it already doesn't do that.
In the end, they all make trade offs depending on the "whim" of the language designer.
Not to mention that Tcl has Unicode in the core, has had Unicode in the core for at least 8 years, and the long and short is that EVERY string operation is Unicode aware.
You can have unicode procedure names, if that was your fancy.
Me too, but I suspect it might take someone of tchrist's level with experience in both languages to give a good answer. I would be interested in how TCL handles the issues tchirst has to deal with outlined in his famous SO post[1].
Note: If you read that post and think, "Wow, Perl requires a lot of setup for unicode and TCP doesn't require nearly as much" without understanding the specifics of why each step is there, and how TCL handles the same issue, you are likely underthinking the issue.
TCL/TK is incredibly powerful to put a GUI in front of a bunch of scripts. You can easily bind a regexp in a log file to events that update widgets. I wish I had learned it 20 years ago.
If by "that" you mean an example of a GUI on top of scripts, the `git gui` and `gitk` that ship with git are in Tcl/Tk and shell out to the git commands that do the work
As others have mentioned, they are very, very not "native UI" friendly - OSX is an especially bad instance - but they do run on all of Git's platforms without a 20MB runtime to go along with them. If Tk's widgets were just a little less harsh, those two would absolutely be my go-to graphical git clients.
We use TCL for almost everything that isn't C/C++, its insanely flexible. You can completely redefine the syntax if you want as there are NO keywords. Meta programming is easy, as all TCL commands follow the same format- Its only con is the lack of widespread use, so sometimes you'll have to write your own packages.
Dont worry to much though, the syntax grows on you :)