Version 83 of Object orientation

Updated 2012-12-30 01:06:57 by pooryorick

Summary

Information about object-oriented programming and Tcl

Description

Object-Oriented Tcl 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. gkubu 2012-06-03 Try [L1 ] (loading may take some time)


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" [L2 ] 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.

Class-Based

AXL
syntax quite similar to itcl
CASTE
based on Common Lisp Object System (CLOS)
ClassyTcl
Tcl and C based versions available
dkfobj
a predecessor of oo2
EGR MAF
multimeda applications framework, includes C++ and Tcl bindings
incr Tcl
one of the most popular object systems for Tcl
jTcl Java-like object interface to Tcl
mkextensions
includes mkClasses, a Tcl object class and methods mechanism
MOST
OOP that can be easily distributed across a network using jcw's Tequila.
OO by dejong
OO extension that works in Tcl 7, Tcl 8, and Jacl
MIT otcl
dynamic Object-Oriented Programming extension for Tcl, featuring program styles, inheritance, meta objects, automatic method combinations, mixing of C and C++
MIT otcl megawidget system
Object Tcl
A Tcl extension that allows one to use object oriented programming concepts from within Tcl and provides a tight object-oriented coupling to C++.
Object Tcl by Nagao Shijo

Prototype-Based

* Functional

Unsorted

 What: obstcl
 Where: http://ptolemy.eecs.berkeley.edu/%7Ejohnr/archives/code/obstcl/
 Description: Small Tcl object system package.
 Updated: 04/1998
 Contact: mailto:[email protected] (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:[email protected] (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:[email protected] (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:[email protected] (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:[email protected] (Sam Shen)
        mailto:[email protected] (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:[email protected] (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:[email protected] (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:[email protected] (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:[email protected] (E. Gkioulekas)

 What: tclframes
 Where: http://sites.netscape.net/tclframes/
 Description: Frameset based OO implemention for Tcl.
 Updated: 11/2000
 Contact: mailto:[email protected] (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:[email protected] (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: [email protected] 

 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:[email protected] (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:[email protected] (Juergen Wagner)
        mailto:[email protected] (Juergen Wagner)

 What: this
 Where: From the contact
 Description: An easy way to build Tcl objects.
 Contact: mailto:[email protected] (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:[email protected] (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:[email protected] (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:[email protected] (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 [L3 ].


The community would benefit greatly from even the most rudimentary OO benchmarking project. Miguel Sofer points out that Doug Bagley's "Shootout" [L4 ] 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 Rogers wrote a "cute and fuzzy" pure-Tcl extension that endows namespaces with inheritance [L5 ].


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.