Main Content

Tcl - a true interpretive, command based language

Archive - Originally posted on "The Horse's Mouth" - 2009-10-20 04:35:35 - Graham Ellis

Tcl is a very different language to the others that I give courses on - it's a truly interpretive language who's structure is based on commands rather than operators and operands. Thank sounds a bit technical - so what does it really mean?

A Truly Interpretive language is interpreted each step along the way. You'll often be told that Perl, Python or Lua is interpreted but that's not really the case - they are "compile and run" languages where the source code is checked once, and an intermediate "Byte code" produced - a slower start to running a program with all that extra work to do ahead of time, but once it's running much faster as the lexical analyzer doesn't have to go "p-r-i-n-t ... oh that's a print" every time around a loop.

And a Command Based Language is one where every instruction starts with a command word - it means that code such as h = 12 isn't valid because that would be looking for a command called "h" with two parameters - an = sign and the string "1-2". This makes the source a little longer and clunkier, but the interpreter far smaller, and much easier for traditional engineers who only do a bit of programming to understand.

So really Tcl is very much closer to Shell Programming than the other so-called scripting languages. Not a problem to us - we cover Shell Programming in Bash briefly on our Linux basics course (and much more on private courses), and Korn Shell Programming on private courses

Footnotes - see here for details of Lua's compiler, and here to read more about how Python does it. Perl's byte code is discussed here, and Java's is widely used - it's the "class file" - and you'll find mentions all over our site - see here for example.