Hacker News new | ask | show | jobs
by bambambazooka 2900 days ago
What makes Tcl special and worth to learn?
2 comments

Tcl is very easy to embed into your application. Tcl has a very simple syntax (with just 13 syntax rules). Tcl is very portable. Tcl supports threads and threading using the apartment threading model, where threads generate messages to send to each other. Tcl is asynchronous event-based. Tcl supports virtual filesystems (and virtual time...). Tcl can be compiled to machine code (TclQuadCode, still in progress, but functional). Tcl supports big integers natively. Tcl has excellent documentation for all the library, C API. Tcl has extreme backwards compatibility for binary extensions since all function calls and most data structures are versioned -- if you compile with Tcl version X, your binary extension will work with Tcl version >=X. Tcl has a large library of extensions and a uniform way to fetch them (Teapot). Tcl-based applications can be compiled into a single executable with their interpreter and other resources for single file deployment (that does not extract to disk and run on the run side, it uses the virtual filesystem capabilities to mount the executable and run from there). Tcl is easy to program in and most new Tcl developer's programs work. Tcl can be as small as you want, if you are willing to give up library support. Tcl has excellent unicode support within the BMP (basic multilingual plane; outside the BMP Tcl needs to be compiled differently than the default, which requires a breaking ABI change, though older extensions will still work thanks to versioning). Tcl is extensible within Tcl -- since most of Tcl is composed of the library and there are very few syntax rules most of Tcl can be modified from within Tcl -- you can rewrite "if" and "for" in Tcl if you want, or create your own control structures. Tcl has an option for Safe Interpreters, which can execute untrusted code safely.

What's not to love ?

(not OP, but hope you don't mind my $0:02)

tcl is what you get when you take shell and lisp, and smash them into each other.

In many ways, its a lisp whose central data structure is the string, rather than than the linked list (so, a sisp?). And instead of macros, you have fexpressions (functions which can decide at runtime whether or not to evaluate its arguments).

When you understand it like that, you can write some elegant code in it. And as it does have proper, efficient data structures under the hood, performance is on par with most other mainstream, traditional "scripting" languages. Although semantically, everything has a string representation - if you're creating a list, and use it as a list, it only exists in memory as a list (as so you dont pay performance costs of auto-casting to and from its string representation).

2 things really tick (goes with tickle, I guess) me off though:

1. because everything has a string rep, its hard to write code which can handle polymorphic types. For example, say a parsing routine which can take either a string, or a list of strings.

You end up having to 'tag' your data somehow (basically, roll your own static typing), which just feels wrong in such a dynamic language.

(could just be my deficiencies in using it, though)

(on the plus side, rolling your own tagging system using tcl ensembles shows just how malleable the language is. You can almost turn it into anything)

2. the parser could do with some changes. Too much tcl code just looks ugly because you (well, I) can't indent it the way I would like. So you (err, I) end up with /'s everywhere.

Bottomline: tcl is so close to being the perfect drop-in replacement for bash (if only the last extra yard was taken) that its painful to go back to using bash for, well, anything.

(sorry for the late reply, just saw this now)

Thanks for the info - reading your pdf now :-)