3 ms·
I am a huge fan of Tcl. It's one of those languages that can be intimidating up front (when do I need $ and when not? etc) but it is in fact enormously simple o
by gaius 18y ago
I am a huge fan of Tcl. It's one of those languages that can be intimidating up front (when do I need $ and when not? etc) but it is in fact enormously simple once you get used to concepts like "everything is a command". There is no syntax. # (the comment character) is a command that ignores all its arguments. Tcl's event model makes many classes of applications (network servers, GUIs) much easier to write than in multi-threaded languages (tho' Tcl does do threads too if you need them).
The ability of Tcl to implement new control structures (e.g. Tcl doesn't have do...while but you can easily add it yourself) puts it up there with Lisp as a programmable programming language... I really don't understand why it isn't more popular with hackers. The tcl.tk Wiki has some "Lisplay" articles where people have experimented with Lisp-style coding in Tcl, it's surprisingly easy. And Tcl has the real-world libraries (e.g. GUI, Oracle access, etc) that working programmers need.
- astrec 18y agoThere's also AOLserver which still holds up as a nice app server.
- SwellJoe 18y agoThe first iteration of our website ran OpenACS on AOLServer. It was an interesting experience. I actually found AOLServer quite charming...but OpenACS, not so much. I didn't really have any complaints about Tcl, as a language, but OpenACS was really difficult to work with. It seemed like second system effect had had its way with the whole project and in a bad way. So, I ended up scrapping OpenACS and AOLServer, and I haven't touched Tcl since.
- kragen 18y agoI don't think hackers hate Tcl because it's "intimidating". They hate it because it's verbose, slow, and lacking in abstraction power. (Last time I used it, associative arrays weren't first-class, i.e. you can't have a list of anonymous associative arrays; is that still the case?) Also, Tcl was originally aimed at the niche that Lua now occupies — lightweight embedded scripting language — but Tcl is 720k of code while Lua is 82k, and isn't verbose, slow, or lacking in power. Finally, the libraries available for Tcl, while they do cover some pretty important stuff, are a tiny fraction of what's available for C, C++, C#, Java, Perl, Python, or even Ruby. The article says it's "more or less as fast as ... Ruby". Well, that's pretty slow! The string-substitution execution model is easy to explain, and it's easy to do higher-order programming with, but it's very error-prone and very difficult to implement efficiently. If you use Tcl in a disciplined way, you won't have too much trouble with this, but it is not nearly the advantage that this article makes it out to be. Tcl does have some nice advantages: it's optimized for use as a UI with an embedded DSL, not for use as a programming language, and its support for event-driven programming and securely running untrusted code are first-rate. Yosef K. (Yossi Kreinin) recently blogged about some of this. Oh, and you say, "# is a command that ignores its arguments". You're wrong about that; try "# [set x 3]" or "# comments do not end at semicolons; puts hello" if you don't believe me.
- pmarin 18y agoWell, Tcl is faster than Ruby and now we don't use the associative arrays we use the dict instead. What version of tcl have you used?
- kragen 18y agoYou seem to think that dicts aren't associative arrays. I think the last version I did any significant amount of work on was Tcl 8.3. But I wasn't any kind of expert on it then. It might be true that Tcl (8.6?) is faster than Ruby now, but the article that started this thread didn't dare to claim that, and these benchmarks of Tcl 8.5b3 don't support that claim: http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=tcl&lang2=yarv http://shootout.alioth.debian.org/gp4/benchmark.php?test=all...
- pmarin 18y ago# [set x 3] set x can't read "x": no such variable # puts hello --nothing happens-- What are you talking about?
- kragen 18y agoCompare the behavior of # to the behavior of puts. If you puts [set x 3], not only does it print out 3, it also sets x to 3. If you # [set x 3], it does not set x to 3, because # is not actually a command that ignores its arguments; it is a comment, just like in Python, Perl, or sh. Similarly, if # were a command, a semicolon would terminate it and start a new command, but it doesn't. The comment continues to the end of the line.
- gaius 18y agoIf # were a comment character in the language you could do this: % puts "hello" # hello bad argument "hello": should be "nonewline" But this works: % puts "hello" ;# hello hello That's the point; that nothing in Tcl is "special" or "reserved", everything is a command that takes parameters.