Updated 2011-07-20 02:04:16 by RLE

Purpose - point to (and describe in-line where appropriate) what the term 'Object orientation' means with regards to Tcl.

Object-Oriented Tcl [1] is a magazine article from July 2004 that introduces the subject for those unfamiliar with Tcl.

EG 2009-09-20 The above link is unavailable.

See the TclOO framework which will be bundled with Tcl 8.6 core.

Discussion - what do you mean when you say "Object orientation"? What must be present for a programming language to be considered OO to you?

When I say "object orientation", I refer to Grady Booch's definition: Object-oriented analysis and design's underlying concept is that one should model software systems as collections of cooperating objects, treating individual objects as instances of a class within a hierarchy of classes. I expect the ability to define my own hierarchy of classes (inheritance), where the classes define objects' data and behavior, and I expect the ability to separate interface and implementation. - RWT 10/30/00

"Objects in Tcl" [2] by Koen van Damme gives a guided tour of creating pure-Tcl objects without inheritance. See also Gadgets, LOST, and MOST. For a minimal pure-Tcl OO system that allows (but not requires) to distinguish objects and classes, see On things - Doing things in namespaces - Chaining things. In yet another weekend, RS has been playing OO. See also playing oo design.

DKF: Fundamentally, OO in Tcl means that you've got an ensemble-like command (i.e. a command with subcommands) and some internal state model associated with that command (and manipulated by the subcommands) that goes away when the object is destroyed. That's all that's required. Everything else (including classes) is optional, if often useful to have. Note that according to this definition, Tk uses an object system for its widgets.

wdb: The benefit of object orientation is doubtlessly its information-saving and hiding capability. Possibly oo is mainstream nowadays. If a language is purely object-oriented such as Ruby, then it is ok. But oo is not the one true solution. If a language has a different paradigma such as Tcl and others, then it's nice to have the opportunity to use oo, but not to forget that there are other mechanisms of information hiding. I have used both, Itcl and Snit, and both do a good job in their way, but in some cases I prefer more language-generic mechanisms such as procedures originated in namespaces where they have private information as well. The true benefit of Tcl is imho the opportunity to use more than one oo extension in one application. This makes Tcl unique compared with the other scripting languages.

Brief List of Popular OO Frameworks for Tcl

Since the comprehensive list (below) has grown very long, here is a short list (in no particular order) of some OO frameworks that are in very widespread use.


Comprehensive List of OO Frameworks for Tcl

What Tcl extensions attempt to provide some framework of OO support? For each extension, add info about what features make this extension unique. Also, add information regarding the level of support available for the extension. Finally, add URLs for the extension as well as for some practical uses for the extension.

Some of these frameworks are intended for general-purpose deployment; others were developed to satisfy the requirements of a specific project. Some of these frameworks are no longer maintained.

Category Object Orientation lists several other projects that use a minimum of code to provide a subset of object-oriented facilities.

 What: BOS
 Where: ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/bos-1.31.tar.gz      -- procplace is gone
        ftp://ftp.cs.cmu.edu/afs/cs/user/snl/pub/bos-1.31.tar.z
 Description: BOS - the Basic Object System; SELF-like Tcl objects extension.
 Updated: 10/1998
 Contact: mailto:snl+bos-requests@cmu.edu (Admin. requests for BOS mailing list)
        mailto:snl+box@cmu.edu (BOS mailing list)

 What: CASTE
 Where: From the contact
 Description: o-o programming based on Common Lisp Object System (CLOS)
 Contact: mailto:braver@cs.berkeley.edu (Michael Braverman)

 What: ClassyTcl
 Where: http://classytcl.sourceforge.net/index.html
           (the below do not work as of 3/31/2010)
        http://rrna.uia.ac.be/classytcl/
        http://rrna.uia.ac.be/classytcl/prog/ClassyTcl-1.0.0.src.tar.gz
        http://rrna.uia.ac.be/classytcl/prog/ClassyTk-1.0.0.src.tar.gz
 Description: Dynamically loadable object system (tcl or C based).
        The system is simple, but flexible. Classes and objects
        are dynamic, and can easily be queried, changed and
        debugged at runtime.
        ClassyTk is based on this system and provides a widget set
        and GUI builder.
        Widget set includes BarChart, ChartGrid, LineChart,
        Balloon (help), CmdWidget (command line widget),
        DefaultMenu (select from user defined defaults),
        DragDrop, DynaMenu, DynaTool (toolbar), FileSelect,
        InputDialog, ProgressDialog, SaveDialog, SelectDialog,
        getcolor, getfont, yorn, Browser, Editor, Fold
        (foldable frame), HTML, MultiFrame, NoteBook,
        OptionBox, OptionMenu, Paned, Progress, Table,
        Tree, ColorEntry, FontSelect, Selector, as well as
        improved versions of Canvas, Entry, FileEntry, ListBox,
        Message, NumEntry, RepeatButton, ScrolledFrame, Text,
        and more.
        Comes with sample applications such as cedit,
        ccalc (calculator), cdraw (vector drawing),
        ctester (test ClassyTcl widgets), cfiles (early stage
        file manager), ccenter (early stage program manager).
        Requires Tcl/Tk 8.x and ExtraL if ClassyTk widgets are used.
 Updated: 08/2001
 Contact: mailto:derijkp@uia.ua.ac.be (Peter.DeRijk)

 What: dkfobj
 Where: http://www.man.ac.uk/~zzcgudf/tcl/dkfobj.tar.gz
        http://www.man.ac.uk/~zzcgudf/tcl/#scripts/fasteval
 Description: A Tcl8 fast object oriented programming extension.
        This is a full object system for Tcl8 that provides classes,
        objects, methods, properties and inheritance - all the things you
        really need. This uses an enhanced version of the fasteval code
        also available at the site.
 Updated: 06/2000
 Contact: mailto:donal.k.fellows@man.ac.uk (Donal K. Fellows)

DKF: As the author of the above, I am convinced you can do better elsewhere nowadays...
 What: EGR MAF
 Where: http://www.easterngraphics.com/products/maf/
 Description: EGR's Multimedia Applications Framework is an OO
        application framework for distributed multimedia.
        Includes C++ and Tcl bindings.
        IRIX 5.3, Solaris 2, and NetBSD are supported.
        Commercial product.
 Updated: 04/1999
 Contact: mailto:info@easterngraphics.com

What: incr Tcl Where: see the Wiki page, as well as BOOK incr Tcl from the Ground Up
 What: jTcl
 Where: http://www.fridu.com/                            -- no longer there
        http://www.fridu.com/Html/jTcl.html
        http://www.fridu.com/Html/download.html
 Description: A flying Tcl parser allowing Java-like object interface
        to Tcl.  Provides debugging facilities, network classes, rules
        server, serialization mechanism, and a package mechanism similar
        to Java's import.
        Class libraries for generic tcp client/server, web serving,
        application serving, session serving, and rule serving are
        provided.  Demos of chat, web, and rule servers are provided.
        Allows one to design web applications in Tcl with a Java syntax.
        It is Tcl only, requires no extensions,
        and runs on all platforms supporting Tcl.
 Updated: 10/1998
 Contact: mailto:phillf@fridu.com (Philippe Le Foll)

 What: Miscellaneous Tcl procs (Kraus)
 Where: http://mkextensions.sf.net/
 Description: mkGeneric - a collection of Tcl 8 commands that contact
        found missing.  Includes a variety of math functions, list functions
        programming constructs, output options, etc.
        mkClasses - a Tcl object class and methods mechanism,
        mkTables - a collection of Tcl scripts that treat lists as if they
        were 'tables' (a list whose elements are themselves lists),
        mkThreads - thread support for Tcl/Tk scripts,
        mkTulip - arbitrary precision math
        mkWidgets - metawidget support, based on mkGeneric and mkClasses,
        and other goodies.
 Updated: 11/2002
 Contact: mailto:mailto:mmg_kraus@csi.com (Michael Kraus)

 What: MOST
 Where: http://wiki.tcl.tk/MOST
 Description: Miniature Object System for Tequila - provides OOP that
        can be easily distributed across a network using jcw's Tequila.
 Contact: mailto:larry@wildopensource.com (Larry Smith)

 What: OO
 Where: http://www.cs.umn.edu/%7Edejong/tcl/OO.zip
 Description: OO extension that works in Tcl 7, Tcl 8, and Jacl.
 Updated: 08/1998
 Contact: mailto:dejong at cs.umn.edu

 What: MIT otcl
 Where: ftp://ftp.tns.lcs.mit.edu/pub/otcl/
        ftp://mohegan.wi-inf.uni-essen.de/pub/otcl-0.96b.tar.gz
        http://netweb.usc.edu/%7Ehaoboy/
        http://www-mash.cs.berkeley.edu/dist/otcl-1.0a3.tar.gz
 Description: MIT Object Tcl is a dynamic Object-Oriented Programming
        extension for Tcl, featuring program styles, inheritance,
        meta objects, automatic method combinations, mixing of C and C++.
        Works with Tcl 7.[345].
        The author no longer actively supports the tool.  However,
        a large user base for the extension exists at the mash
        web site, connected to "ns", a network simulator that is
        commonly used.  They have ported otcl to Tcl/Tk 8.0
        The version from Germany contains a set of fixes for various
        destroy problems discovered by Martin Andrews and Gustaf
        Neumann.
        The usc site is Haobo Yu's port of MIT otcl to Tcl 8.0b2.
        The berkeley site is the site of a project which depends on otcl -
        they too have ported it to Tcl 8.0.
 Updated: 01/1999
 Contact: mailto:andrewm@ccfadm.eeg.ccf.org (Martin Andrews)
        mailto:Gustaf.Neumann@uni-essen.de
        mailto:haoboy@isi.edu (Haobo Yu)

 What: MIT otcl extensions and patches
 Where: From the contact
 Description: Contact has posted a couple of patches, including one
        that gives "gensym" support - by specifying gensym as the name
        of the object, a unique object name is returned.
 Updated:
 Contact: mailto:hildjj@fuentez.com (Joe Hildebrand) (???)

 What: MIT otcl mega-widget system
 Where: From the contact
 Description: A simple otcl mega-widget system.  Unsupported.
 Updated:
 Contact: mailto:andrewm@ccfadm.eeg.ccf.org (Martin Andrews)

What: Object Tcl
 Where: ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/oop/ObjectTcl.1.0.tar.gz        -- procplace is gone
        http://ftp.uni-siegen.de/x11/tcl/ftp.gmd.de/contrib/alcatel/extensions/ObjectTcl.1.0.tar.gz
 Description: A Tcl extension that allows one to use object
        oriented programming concepts from within Tcl and
        provides a tight object-oriented coupling to C++.
        Can be used freely for non-commercial purposes;
        email the contact for commercial use licensing details.
 Updated: 10/1998
 Contact: mailto:otcl@x.co.uk (Object Tcl)

 What: Object-Tcl
 Where: http://www.hf.rim.or.jp/%7Enagao/object-tcl-2.0-snap.tar.gz
 Description: A simple script only OOP extension for Tcl.
        This extension provides class with multi inheritance and configuration
        methods which is similar to that of Tk widgets. The OOP features are
        constructed with minimal system commands that has simple interface and
        proper error message handling, minimal quirks and minimal overhead.
        It is very easy to create a new combined widget from original
        widget set.  The namespace facility in Tcl8.0 is completely supported
        by version 2.0. The system works on both Tcl7.* and Tcl8.0.
        Currently, the only development snapshot is available from the
        WWW server.
 Updated: 12/1997
 Contact: mailto:nagao@hf.rim.or.jp (Nagao Shijo)

 What: obstcl
 Where: http://ptolemy.eecs.berkeley.edu/%7Ejohnr/archives/code/obstcl/
 Description: Small Tcl object system package.
 Updated: 04/1998
 Contact: mailto:johnr@kahn.eecs.berkeley.edu (John Reekie)

 What: obTcl
 Where: ftp://ftp.dynas.se/pub/tcl/obTcl.tar.gz
        ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/obTcl-0.56.tar.gz          -- procplace is gone
        ftp://ftp.uni-hannover.de/pub/mirror/tcl/mirror/ftp.procplace.com/alcatel/potpourri/obTcl-0.56.tar.gz
 Description: A Tcl 7.[45] object and megawidget extension, supporting multiple
        inheritance, three new storage classes, and fully transparent
        Tk megawidgets.  If you need a Tab/Notebook widget or a
        Paned Window widget, but only want to use standard Tk, this
        extension might be for you.  Now has an optional loadable accelerator
        module (which requires use of Tcl 7.5) .
        Current version is 0.56.
 Updated: 10/1998
 Contact: mailto:patrik@dynas.se (Patik Floding)

 What: Pool
 Where: http://www.purl.org/NET/akupries/soft/pool/
        http://www.purl.org/NET/akupries/soft/pool/download/pool2.2.tar.gz
 Description: A personal library of Tcl procedures.  Requires Tcl/Tk 8.x.
        Contains calendar widgets, date, string, list and file manipulation
        functions, option processing routines, url manipulation and
        extraction routines, yet another OO (object-oriented) tcl based
        system, and megawidget support.
 Updated: 11/1999
 Contact: mailto:a.kupries@westend.com (Andreas Kupries)

 What: scwoop
 Where: http://jfontain.free.fr/scwoop.htm
        http://jfontain.free.fr/scwoop-3.1.tar.gz
 Description: Simple Composite Widget Object Oriented Package is implemented
        in a single sourcable file and uses simple techniques to provide
        composite widget (mega widget) support to Tk.  Uses stooop 4.1
        and above.  Runs on all Tcl 8.3 or higher supported platforms.
        Full HTML doc, with live tclets, are provided at the web site.
 Updated: 02/2000
 Contact: mailto:jfontain@free.fr (Jean-Luc Fontaine)

What: Snit's Not Incr Tcl
 Where: http://www.wjduquette.com/snit
 Description: See wiki page listed above.  Snit provides simple object
        and mega-widget support based on delegation rather than inheritance;
        it's designed to work with anything that resembles a typical Tcl/Tk
        object command.  For example, a Snit megawidget can delegate methods and
        options to Tk widgets, Incr Widgets, BWidgets, and just about anything
        else.

 What: SNTL
 Where: http://www.csua.berkeley.edu/%7Esls/woa/distrib/
        ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/sntl-0.4.2.tar.gz         -- procplace is gone
        ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/sntl-0.4.2p1.patch.tar.gz
 Description: A general Tcl library of procedures.  Contains code to
        produce man pages from Tcl source, conversions from Tcl to C,
        HTML rendering, generating HTML, handling CGI forms, command line
        argument processing, a debugging message system, an object system,
        and various Tk widgets built with the object system.
 Updated: 10/1998
 Contact: mailto:slshen@lbl.gov (Sam Shen)
        mailto:sls@aero.org (Sam Shen)

 What: STERNO
 Where: ftp://ftp.procplace.com/pub/tcl/TclX/sterno0.3.tar.gz      -- procplace is gone
 Description: STERNO - Simple Tcl Extra Really Nice Objects - is a simple
        object system for Tcl implemented in Tcl.  It is designed for
        structured data encapsulation and management.  It is not intended
        to replace itcl - for instance, there is currently no inheritance.
        Built on top of Tcl 8.0 namespace, it was developed because it
        was needed by the contact.
 Updated: 10/1998
 Contact: mailto:markd@grizzly.com (Mark Diekhans)

What: stooop
 Where: See the above wiki page.

What: LOST
 Where: http://wiki.tcl.tk/923
 Description: LOST - Lightweight Object System for Tcl
        Lightweight Object Systems for Tcl, providing a tiny but highly
        functional object system.  LOST (http://wiki.tcl.tk/923) is a
        38 line Tcl script that creates class procs for object variables,
        enabling a [objname method arg1...] syntax. LOST uses "init"
        (http://wiki.tcl.tk/10876) for argument parsing.
 Updated: 09/2007
 Contact: mailto:larry@smith-house.org (Larry Smith)

What: MOST
 Where: http://wiki.tcl.tk/14893
 Description: MOST - Miniature Object System for Tequila
        MOST creates an object system that duplicates the one provided
        by LOST.  However, rather than keeping object data in procs,
        this one keeps it in arrays.  Since Tequila (http://wiki.tcl.tk/1243)
        provides a way to distribute and share Tcl arrays, this means you
        can create distributed network objects by adding the Tequila "attach"
        command - one line standing between you and a powerful distributed
        network object system.  No other object system for Tcl includes this
        functionality.
 Updated: 09/2007
 Contact: mailto:larry@smith-house.org (Larry Smith)

What: Poet
 What: Tcl++/Tk++
 Where: http://www.amath.washington.edu/%7Elf/software/tcl++/
 Description: A package that makes development of extended Tcl/Tk
        interpreters easier and more pleasant for C++ programmers.
        It does not patch the core, nor need the Tcl internals.
        This also includes a small object oriented extension as well
        as some widgets for Tk.
        Further development of Tcl++ is on hold right now.  Mr. Gkioulekas might have renamed this package "tclpp" to avoid conflict with Matt Newman's Tcl++, although this raises a question about any relation to Stefan Sinnige's tclpp.
 Updated: 07/1998
 Contact: mailto:egkioule@u.washington.edu (E. Gkioulekas)

 What: tclframes
 Where: http://sites.netscape.net/tclframes/
 Description: Frameset based OO implemention for Tcl.
 Updated: 11/2000
 Contact: mailto:fugate@lucent.com (Cris A Fugate)

 What: Tclpp
 Where: http://www.geocities.com/SiliconValley/Network/2836/projects/tclpp/
 Description: Tcl 8 based object oriented extension.  Provides Java or C++
        object syntax to Tcl.  Adds items like multiple inheritance,
        data encapsulation, virtual functions and RTTI (Run Time Type Info).
        Currently at version 2.0.
 Updated: 06/2000
 Contact: mailto:ssinnige@geocities.com (Stefan Sinnige)

 What: Tclaop
 Where: http://www.eriskouma.com/default/all/en/tclaop.html
 Description: Aspect Oriented Programming extension (experimental).
        Based on the good work of stefan Sinninge Tclpp (version 1.2,
        pure tcl script).
 Updated: 11/2002
 Contact: paolo@eriskouma.com

 What: Tea
 Where: http://members.xoom.com/iliadtools2/tea/
        http://members.xoom.com/iliadtools2/tea/tea-3.0.tar.gz
 Description: Tcl 8 based object oriented extension.  Tea follows the Java
        model, trying to implement the look of Java from a class definition
        perspective, yet remain syntactically consistent with Tcl.  Written
        in Tcl 8 source code.  Classes can be put into a zip archive.
 Updated: 02/2000
 Contact: mailto:johnstump@iname.com (John Stump)

 What: theObjects
 Where: ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/theObjects-3.1.tar.gz      -- procplace is gone
 Description: Small prototype-oriented object system.
 Updated: 10/1998
 Contact: mailto:Juergen.Wagner@iao.fhg.de (Juergen Wagner)
        mailto:gandalf@Csli.Stanford.EDU (Juergen Wagner)

 What: this
 Where: From the contact
 Description: An easy way to build Tcl objects.
 Contact: mailto:cball@etsd.ml.com (Charles Ballance)

 What: TODL
 Where: http://users.pandora.be/koen.vandamme1/tcl_tools/todl/todl.txt
        http://users.pandora.be/koen.vandamme1/tcl_tools/todl/todl.tgz
 Description: Simple library and tools for object support in Tcl.
 Updated: 12/2000
 Contact: mailto:koen.vandamme1 at pandora.be

 What: TOS
 Where: http://www2.lifl.fr/%7Epawlak/tos
 Description: Tcl Object System (TOS) is another Tcl extension for object
        oriented programming, this one having full reflectiveness.
        Contains special objects called Class, Metaclass, and Object
        that control the base object behavior and devinitions.
        Currently at version 2.3.1 .
 Updated: 11/2006
 Contact: mailto:pawlak@cnam.fr (Renaud Pawlak)

 What: TWO - Tcl With Objects
 Where: ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/tclwobjects1.tar.gz      -- procplace is gone
 Description: Tcl-based simple objects.  Instance variables are accessed
        just like local variables.
 Updated: 10/1998
 Contact: mailto:aginter@cuug.ab.ca (Andrew Ginter)

 What: [XOTcl]
 Where: http://www.xotcl.org/ http://media.wu-wien.ac.at/
 Description: Extended OTcl - exotickle - is a value added replacement of
        the MIT OTcl object extension.  In addition to all the OTcl
        bonuses like meta-classes, multiple inheritance and read/write
        introspection, XOTcl adds Per-Objects Mix-ins, Filters,
        Nested Classes, Dynamic Object aggregations, metadata
        and assertions. All of these features together allow easy
        construction of high-level patterns and structures and
        simultaneously follow the Tao of Tcl.
 Updated: 06/2001
 Contact: mailto:uwe.zdun@uni-essen.de (Uwe Zdun)

Yet another object system does everything with lists. Procs as objects does it with default arguments to procs, instance variables might be kept in alias only.

SDynObject is a pure Tcl system that is very simple and extensible.

TOE -- Toe is an extension to the Tcl programming language that enables object-oriented (OO) programming in a class-based, Java-like style. Toe provides commands that allow a Tcl scripting programmer to create OO classes, define functional relationships between classes, run Tcl code in objects created from the classes, and implement various multiple-class patterns that are well-known in the object-oriented paradigm.

A lightly annotated index to most of the same packages appears at [3].

The community would benefit greatly from even the most rudimentary OO benchmarking project. Miguel Sofer points out that Doug Bagley's "Shootout" [4] includes "Object Instantiation" and "Method Calls" items which might to inspire Tcl-specific designs.

SLB You mean like Comparing Performance of Tcl OO extensions?

Tcl appears ambivalent, at best, about object orientation. Darren New has suggested that "the need for OO techniques is greatly reduced by a language with eval and info and dynamically-sized structures built in." DKF finds subclassing for GUI configuration suboptimal.

John Buckman has written a tiny (<100 lines) OOP toolkit called BOOP (for "Basic OOP") which is super-simple, aimed at people who want a small amount of object oriented functionality (objects, member functions, memory cleanup, member vars) implemented in simple, comprehensible Tcl that won't gum up your environment, complexify your debugging or break debuggers.

In 2001, [Mike Rodgers] wrote a "cute and fuzzy" pure-Tcl extension that endows namespaces with inheritance [5].

See also Writing Extensions and, in an entirely different direction, RS's many demonstrations, including "Playing with Circuits", of how OO can be a stylistic matter, without syntactic scaffolding.

See also:

Kristoffer Lawson (aka setok) has made a package of his Selfish object system, done in pure Tcl.

See TIPs:

for some of the history of proposed object orientation for Tcl.

See thoughts on implementing OO in tcl.