My favorite Tcl package

Well, originally I wanted to write down a list of my favorite of Tcl packages and then post about that. But after I wrote them down, I found that this list had only one entry: William Duquette’s snit.
Out of the multitude of OO extensions we have for Tcl, this is the one I use pretty much exclusively. When I have to structure my data in some manner, writing a snit::type is the first thought that comes to mind, and the first action taken. If a mega-widget is needed, a snit::widget (or widgetadaptor) is the thing to make. It has captured me that much.
Why has that happened? I am not fully sure. I guess it is several things.

  • It feels like Tcl. One of Tcl’s advantages is, IMHO, how easy it is to make and put building blocks together like Lego. snit behaves in the same way, making it easy and convenient to create and use bricks. The use of ‘delegation’ instead of ‘inheritance’ seems to be a major factor in this. No need to create elaborate class hierarchies; just pull the blocks you need together.
  • It also makes a number of things easy and pretty much automatic which normally require the boring writing of much boilerplate, like the definition and handling of options for widgets, including validation of values. A bit more esoteric in this area, hierarchical methods are convenient to write as well. You don’t need to write your own helper dispatch methods and code, snit does it for you.

This was all especially put into focus with the arrival of Tcl’s official OO package, TclOO, integrated in the upcoming Tcl 8.6. As nice as this package is, with novel features likes mixins and filters, and also being much faster than snit, I still go for snit first, because TclOO doesn’t have the nice option handling yet, nor the hierarchical methods. I really don’t want to write my own code for this after having snit do it for me for so long. I guess it has spoiled me.
So, which Tcl package is your favorite, and why?

Recent Posts

Scroll to Top