4 ms·
I don't know when you last worked with Tcl, but it's got lists (as always), dictionaries, and integrated first-class object system (after years of various exten
by bch 11y ago
I don't know when you last worked with Tcl, but it's got lists (as always), dictionaries, and integrated first-class object system (after years of various extensions). Also, if it's an option, punting structures to C can be nice to organize data.
Re: abandoned applets - some see that as dodging a bullet. If it became a Big Deal in the browser, it arguably could have cemented itself into the form it had at that time, because of maintaining compatibility for that audience. It's a thought exercise I haven't completely thought through, to be honest, which just occurred to me because Tcl has done a tremendous job being true to itself anyway, and has a great amount of compatibility with historic versions of itself.
Anyway, now I'm off to look at slide rules ;)
- davidw 11y ago> punting structures to C can be nice to organize data I'm a Tcl fan, but the above is actually somewhat problematic, because to hold a reference to the C struct, you have to then manually free it later, losing some of the benefits of a language with automatic memory management. Real dicts, and the new object stuff are big improvements though.
- bch 11y ago> ...the above is actually somewhat problematic, because to hold a reference to the C struct, you have to then manually free it later, losing some of the benefits of a language with automatic memory management. I usually frame the data as clientData passed to a managing command (i.e. custom built first-class command), with appropriate allocation/deallocation. As often as not, I'm creating two commands: an anonymous reference template, and a command-creating-command that will instantiate instances of the "anonymous reference template". Then I can create an arbitrary number of arbitrarily named commands that pack and process their data, including freeing on destruction. To the uninitiated, this sounds like object-oriented programming, which is arguably true, but doesn't automatically come with subclassing, inheritance, etc, etc. Tcl does have first class objects, but what I'm describing here isn't them.
- srean 11y agoQuite curious to take a look if you have anything available for the public eye.
- blacksqr 11y agoFlightAware has released the SpeedTables package for Tcl, which basically creates C structures on the fly, as well as C-based accessor routines: "Speed tables reads a structure definition and emits C code to create and manipulate tables of rows of that structure. This allows operations to be performed on the table at native code speeds, using a custom extension that manages rows of fields as native C structs and emit subroutines for manipulating those rows in an efficient manner." FlightAware.com deals with extremely high-volume data throughput, and they manage the whole process with Tcl. https://github.com/flightaware/speedtables https://github.com/flightaware/speedtables
- davidw 11y agoCool! They run https://tcl.apache.org/rivet/ https://tcl.apache.org/rivet/ too, which I played a part in building.
- kragen 11y agoIt pretty much is cemented into the form it had at that time. My 1997 code runs in current Tcl/Tk, although I had at some point broken it by adding a #comment without a semicolon before it, but that was never valid. I think Tcl introduced some incompatibilities around 1992 or 1993, since the old icb client I used, which embedded an early version of Tcl from around that time, had some incompatibilities with scripts written in Tcl 4. 1997 is probably pretty close to the last time I worked with Tcl. Tcl lists and arrays (dictionaries) are great, but arrays aren't first-class; you can't pass them as arguments or return them from expressions, only store them in variables. I'd argue that TclOO objects aren't first-class either: you don't have to explicitly destroy strings or lists (which are strings!) or even arrays when you're done with them, but you do have to explicitly destroy TclOO objects, just like Tk widgets. I don't mean to imply that the object-graph memory model used by Lisp, Python, Perl 5, Java, ML, and Ruby has no disadvantages compared to the flatter memory model used by Tcl, Perl 4, and awk. But usually, for the things I do in low-performance interpreters, the disadvantages of the object-graph memory model are less compelling than the advantages. (I have some draft notes on this at http://canonical.org/~kragen/memory-models http://canonical.org/~kragen/memory-models, if you're interested.) I hope you enjoy the slide rule :)
- bch 11y ago> Tcl lists and arrays (dictionaries) are great, but arrays aren't first-class... I forgot about arrays, tbh. I personally don't like the "feel" of them. The dictionaries I was referring to are these guys: https://www.tcl.tk/man/tcl/TclCmd/dict.htm https://www.tcl.tk/man/tcl/TclCmd/dict.htm Nice to hear your thoughts on the matter, though. Cheers.