Version 8 of Salvatore Sanfilippo

Updated 2003-08-04 08:42:01

Some kind of hacker (davidw was too kind with me in the last version of this page ;).

I like TCL, while there are a number of changes I propose (look forward on this page).

Why I like TCL?

For the following reasons: TCL is the glue able to combine data and code in a direct and expressive way, without tons of special rules, but with few basic ideas that works accross the whole language, in an orthogonal way. Also TCL doesn't force you to take the language as it is, you can extend TCL in itself, so eventually you start programming bottom-up like in lisp-like languages. In TCL like in Lisp it's possible to adapt the language to fit well the application you are writing, then to write the application in this new language. So after all I like TCL for the same reasons I like Scheme, but I tend to use they for very different tasks: when I need the ability to work a lot with strings, regexps, libarires, mix with C code, TCL is my way to go.

For what I use TCL?:

  • One-page scripts that do a lot of works with sockets, files, regexps, and so
  • Vertical programs with GUI that I use to sell to my customers
  • My own experiment with new interesting ways to use the server/client model
  • I'm starting to use it for web programming
  • Random hacking where all-is-a-string-and-i-like-to-eval-it comes handly

And of course I use it a lot when I think to major ideas in programming languages. TCL, like Lisp and SmallTalk, have something of special in the design.

I know TCL thanks to davidw, he used to show me the main ideas, and after some time I got in love of the language (at the point to write a TCL-like programming language that is nowaday just a dead piece of code into my HD). Since then I used many other languages with the same target, such Python, but I like much more the flexibility of TCL.

Other languages I like are: C, Scheme, SmallTalk, FORTH.

How to make TCL better in my opinion

In short:

  • Don't make math an exception in the language, expr should be just an optional,

but the core language should support math using commands like +, *, / and so on, with lisp-like semanthics so that

 [/ 1 2] => 1/2

Also native support for bignums seems to fit perferctly in TCL.

  • No implicit expr inside if, while, and so on.
  • Insert inside TCL a very fast vertical programming language, that's good to

compute algorithmical code.This language should be in my opionion stack-based, somethink like FORTH with a type system and a bit more safe. The TCL interface for this language should be just one command:

 set result [stackbasedlanguage {stack description as TCL list} {source code}]

The command will return a TCL list with the image of the stack after the computation. The first arguments describes the stack, as pairs of {type value}, the format is the same for the result. In my opionion this language should be dynamically typed (with support for FORTH new-style locals), with strong types. The following is a possible usage example:

  porc fast_gcd {a b} {
    set res [ stackbasedlanguage "int $a int $b" {
       def gcd [ (a b)
         a b < IF swap ENDIF
         b 0 !=
         IF
           b a b % gcd
         ELSE
           a
         ENDIF
       ]
       gcd
    }
    return [lindex $res 1]
  }

Ok, that's the main idea. The language should not be general purpose of course, but specifically designed to work very well with numerical algorithms. It's just a way to write a faster inner loop without to use C. Of course the GCD example is not very good, think about TkPhotoLab using this to get a better example. Another way to make it more powerful is the ability to execute TCL code from the stack based language. This will help in special tasks, for example displaying a 3D image using tk from the inner loop of a stack based program.

  • Minimal TCL core, just what is needed to define the language. All the rest are libraries.
  • Support for references
  • A standard support for packet oriented protocols like UDP
  • Maybe some kind of macro system to try new ideas for the language in short time