How Tcl is special

Everything is a string (MS moved some comments from here to that page)

unknown

trace

send

introspection

the idea of scripting

event-oriented programming

simplicity

slave interpreters

The pipeline

temporal arithmetic: Among the Tcl testimonials is Tony Summerfelt's that, "if i need a program that does any kind of heavy duty date manipulation I use tcl. The clock command is easily my favorite in tcl."


Jacob Levy 2003-06-05 Methinks Tcl has the best and simplest thread abstraction available.


KJN 2004-11-29 upvar, uplevel, and the fact that language constructs have the same syntax as function calls.

  • You can write your own language constructs if you don't like the ones supplied with Tcl
  • You can use upvar if you intend to access a variable in the calling scope; in some languages this is impossible; in others, dynamic scoping makes all such variables accessible (a likely cause of bugs). Likewise, lexical scoping can be implemented with namespaces when the programmer requires it. Again, a much better solution in most situations than enforcing it "never" or "always".

KJN 2004-12-01 the ability to replace Tcl commands with user-defined functions. The use of puts by the interpreter for all Tcl output on stdout and stderr (not just for output where the programmer has used a puts statement). Therefore, if puts is replaced with a user-defined function, that function captures all output, even error messages.


KJN 2004-12-01 delivery of Tcl and Tk as shared libraries by default. Even tclsh and wish use these shared libraries. Embedding the interpreter in an application is therefore the norm.


Also see "idiom", "What is the advantage of Tcl over Perl", "Beginning Tcl", "Tcl warts", "Arts and Crafts of Tcl-Tk Programming", "Is white space significant in Tcl", "Tcl Heritage", "What is Tcl", "Tcl and other languages", Is Tcl different!, "Why to use Tcl" [L1 ],


PYK 2017-05-09:

set list {}
while {[incr i] < 100} {
    set number [expr {entier(rand() * 100)}]
    if {$number > [lindex $list end]} {
        lappend list $number
    }
}
set list

This produces an ordered list of numbers. What's interesting is that the list starts out empty, and the first comparision is actually against an empty string. In many (most?) languages, this would fail. In Tcl, this type of flexibility is often used to write concise, powerful code.