5 ms·
There was a semi-rebuttal … I think in a post from Brent Welch. Tcl does have things called "arrays", and you use them much as you'd expect. Tom Lord confirmed
by glv 10y ago
There was a semi-rebuttal … I think in a post from Brent Welch. Tcl does have things called "arrays", and you use them much as you'd expect. Tom Lord confirmed later that what he and RMS meant by this was that it didn't have "true arrays" that are laid out contiguously in memory, to be much more efficient. That's a valid criticism: Tcl's arrays are basically dual-use hash tables, much the same as JavaScript's arrays.
The other two things are totally valid. Tcl has no references, so you can't build your own linked list. And all values are (at least semantically) strings, so numeric operations are slow.
But of course, a lot can be done to optimize those things in the implementation, and over time at least some of that optimization was done.
- ArkyBeagle 10y agoLists are a first-class object in Tcl, so it's not clear to me how much of a deficiency not having linked lists is. I've had cases where opening a 'C' program as a pipe and doing heavy number crunching in the 'C' program outperformed native Tcl.
- glv 10y agoWell, right. Tcl was an early example of a trend where key data structures were built into languages and fairly well encapsulated as "one size fits all" abstractions. Computers had become fast enough that for many purposes you didn't have to build a custom list or hash table. That all seems normal to us now, but it was uncommon back then.
- kazinator 10y ago> Lists are a first-class object in Tcl Was that the case in 1994, or are you writing about the current state of Tcl?
- ArkyBeagle 10y agoI believe it's been true since the language first saw light. I didn't get to it until around v7.x around 1995 and lists feature prominently in Osterhout's book.
- bch 10y ago> all values are (at least semantically) strings, so numeric operations are slow. All values are _still_ semantically strings (it's a core tenet of Tcl: "Everything is a string (EIAS)"), and in 1994, they were practically strings, too (that was the implementation). In 1999 w/ Tcl 8.0, Tcl became byte-compiled and adopted "Tcl_Obj" to represent values[0]. The Tcl_Obj (nothing to do w/ object-oriented programming), is what's called a "dual ported" object. It contains a string-representation of it's value (to preserve EIAS), and a "native" value of it's last computed use. For example, if you: % set a 9.0 % expr { $a * 0.01 } The native value of the Tcl_Obj $a refers to will be a float. Repeated calls to $a in a float-context will continue to use this already-computed native value. No need for further string interpolation. [0] http://www.tcl.tk/software/tcltk/8.0.tml http://www.tcl.tk/software/tcltk/8.0.tml [edit: formatting]