We have been using Itcl for years. I've haven't had to code anything in tcl for several years. I recently realized that a new object oriented system has been added to tcl - tclOO! What the heck is this and why does it exist? Is it supposed to replace Itcl?
-
1The author Donal Fellows is a regular here on SO, so he may well respond to your question. In the meantime, you can read more about tclOO here https://www.magicsplat.com/blog/tcl87-oo/index.html – TrojanName Jul 11 '23 at 10:58
-
You may find it helpful to read the **Rationale** here: https://core.tcl-lang.org/tips/doc/trunk/tip/257.md – Colin Macleod Jul 11 '23 at 12:33
-
I read the rational. It didn't say anything about why it is better than Itcl. I believe Itcl is overwhelmingly the most popular OO implementation. Why isn't it part of the "core" language instead of this tclOO thing? We use tcl sparingly. I didn't notice anything lacking or wrong while using Itcl. I agree that having multiple OO systems is silly. – Donald Winston Jul 11 '23 at 12:56
-
If you like Itcl there's nothing to stop you using it - it's even bundled with the Tcl distribution since v8.6, see https://wiki.tcl-lang.org/page/Highlights+of+Tcl+8.6 . However Itcl does have some limitations due to following the C++ model of OO - TclOO is designed to be more flexible. – Colin Macleod Jul 11 '23 at 13:31
-
Donald, you might want to contemplate [Chesterton's Fence](https://fs.blog/chestertons-fence/) – glenn jackman Jul 11 '23 at 13:42
-
I guess the most important thing is tcl programmers will have a proper standard way to code now. They say tclOO is more "flexible". Ok, I'm not not going to argue about it. – Donald Winston Jul 11 '23 at 15:25
-
Probably, the best intro to TclOO: https://www.magicsplat.com/articles/oo.html – Alex P Jul 16 '23 at 12:10
-
I'm gradually writing a tutorial on TclOO, but it's not yet finished. – Donal Fellows Jul 17 '23 at 15:35
1 Answers
I wrote TclOO. I wrote it because I wanted an OO system that didn't exist at that time, and TclOO is pretty close to what I wanted. Quite a few people have agreed with me; I had number of them help me with the design (with the greatest shout-out going to Will Duquette, the author of Snit; his analysis of the problems with existing designs was critical).
The big thing we didn't like about Incr Tcl at the time was that it was difficult to modify classes after creation. That's not how C++ rolls, and so it wasn't ever part of the design goals of Incr Tcl.
The big thing we didn't like about XOTcl (the other object system we looked at in detail) was that it's configuration style interacts badly with variable numbers of arguments. That turned out to be one of those features that, like a thread that when you pull it the whole garment unravels, is foundational to how the object system works.
We had some new ideas about how to manage necessary information on the stack that have turned out to make TclOO largely easier to use than either, at a cost of making methods be definitely not Tcl commands (their C signature has an extra structure reference to the current call context; they're really different). We used those tricks to do the definition script system, which was designed to give the power of XOTcl and most of the feel of Incr Tcl.
I also worked hard to make TclOO really fast. It's mostly due to very aggressive caching and careful control of how many memory allocations appear on the critical path.

- 133,037
- 18
- 149
- 215
-
After the initial creation, some things took on their own internal momentum. As they do. – Donal Fellows Jul 17 '23 at 15:49