3 ms·
> Learning the language is not intuitive and the worst of it all is that I wasn't able to write any tests which would have helped to refactor that mess. Tcl is
by mschaef 3y ago
> Learning the language is not intuitive and the worst of it all is that I wasn't able to write any tests which would have helped to refactor that mess.
Tcl is one of those languages that's centered heavily around a single dominant concept. In Tcl's case, the idea behind the language is that everything is a string and most of the computation is expressed through various forms of string substitution.
The earliest versions of the language were actually implemented this way. Indexing into an array required the interpreter to parse through a string representation of the array looking for the element you requested. Interpretation of code worked the same way - it parsed your code as it went along. Later versions (>=8.0) added the notion of "dual-ported objects. These gave the interpreter the ability to cache more efficient representations of various kinds of object, while retaining its 'string gestalt' principle.
The net of this is a language that's almost totally at odds with the way people think about coding, and yet has a great deal of deep expressive power that's easy to miss. (It's easily possible to do things in Tcl that might have otherwise been limited to something like a Lisp macro or some kind of preprocessing/code-gen technique.)
This general approach can make the experience of using the language initially very difficult, since it's so unexpected and different from the usual previous experience. If it sticks, though, it can be a seductive sort of environment in which to work. Whether or not this is good or bad language design is a bit of an open question, but I'm glad languages like this exist.
> If I recall it correctly there just wasn't a way to write tests because it's not supported.
It's easy enough to write tests directly in C. There are plenty of ways to do tests in Tcl also. (Many of which are benefited by the string nature of the language I describe above.)