TCL

Ting Qiu
Ecosystèmes des langages de programmation
3 min readMay 24, 2017

Introduction

Tcl is a kind of scripting language. It was designed with the goal of being very simple but powerful [1]. It is now 100 or so in the TIOBE ranking, which the majority of programmers never hear of, but it was very popular before the emergence of Java.

In its popular era, computing equipment performance is very low, Unix Shell is the main competitor and LISP is a beautiful bubble. So Tcl was born with the characteristics of these two languages: Shell string expansion, LISP expression priority and space separator. Also, at that time, GUI was just like a baby, so it’s not easy to write GUI program efficiently. Tk graphics library, which was a popular combination with Tcl, allowed the programmer to create GUI applications easily.

However, most programmers today, who use C language more, are not familiar with Tcl. Today, Tcl is more used as an embedded language.

Features

Tcl’s iconic feature can be included in one sentence: Everything is a string, but not just a string. Any Tcl statement has such a format:

CommandName argument1 argument2 … argument

The simplest program “helloworld”, for example, can be written as

~/tcltk$ cat hello.tcl
#!/usr/bin/tclsh
puts stdout {Hello, World!}

Then we save it as a Tcl file named “hello.tcl” and use a command

~/tcltk$ tclsh hello.tcl

to run it. And at last, we can see

~/tcltk$ ./hello.tcl
Hello, World!

As we can see, Tcl is just like the shell command. Tcl interpreter evaluates, expands, or substitutes each part, and finally calls the command. The use of spaces between the parameters is the same as our natural language writing. Is this a coincidence?

Tcl’s difference from other languages is that its command can be defined, including keywords. IF {} THEN {} is a command, as well as while {} {}. In fact you can create any pattern you want. There is a command and keyword’s library, you can always define a new command to replace the old one. Actually, everything can be replaced in Tcl.

Is this important? Yes, magic is here.

You can create your own language, you can create Adapter, Factory, Mediator, State Machine, Event Handler, and so on. At the grammatical level, you can establish a new Construct. Let these things to be a part of the programming language you create, intuitive, concise, fluent, self-description and the best expansion!

Applications

Tcl is now commonly used embedded into C applications, [2] for rapid prototyping , scripted applications, GUIs, and testing. [3] Tcl interpreters are available for many operating systems , allowing Tcl code to run on a wide variety of systems.

Because of the features we mention above, some large software companies are still actively using Tcl today. It can be very fast and simple to change Tcl into their unique Domain Specific Language. In fact, apart from some very basic functions, each company joins a lot of their own needs. It is much like the use of the Linux kernel.

Conclusion

As a language, Tcl may not be the most popular one today. However, this small language is portable, efficient, cross-platform and easy to learn! So Tcl can be integrated in different operating systems. Tcl is not the best language, but it provides an idea: to define a language by yourselves. It’s a good idea to make computing devices more accessible and programming work more descriptive.

Reference

[1] “Language”. Tcl Developer Xchange. Retrieved 2016–11–02

[2] “From the inside flap of Tcl and the Tk Toolkit”, ISBN 0–201–63337-X

[3] “Uses for Tcl/Tk”. Tcl Developer Xchange. Retrieved 2016–11–02

--

--