** Summary ** Information about '''[http://en.wikipedia.org/wiki/Object-oriented_programming%|%object-oriented programming%|%]''' and [Tcl] [APN] For the benefit of newcomers to Tcl who might get confused by the large number of OO extension, the [TclOO] framework is part of the Tcl core language as of version 8.6. It is also available as an extension for 8.5. The list of extensions discussed in this page were created in earlier versions where Tcl lacked a built-in OO facility. The most notable of these, which still have relevance because of widespread use and features, are [incr Tcl] (now built on top of [TclOO]), [Snit] (because of its excellent support for Tk megawidgets) and [XOTcl] (which continues to add leading edge oo capabilities). The rest IMHO are useful only if you are stuck with older versions of Tcl and only of historical interest otherwise. ** Description ** [http://www.unixreview.com/documents/s=9233/ur0407k/ur0407k.html%|%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 [http://web.archive.org/web/20071017181547/www.unixreview.com/documents/s=9233/ur0407k/ur0407k.html] (loading may take some time). [APN] This article is hopelessly out of date. ---- '''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" [http://users.pandora.be/koen.vandamme1/papers/tcl_objects/tcl_objects.html] 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. * [incr Tcl] or '''itcl''' - binary package, bundled with [ActiveTcl] and also built into [Tclkit]. [incr Tk] and [Iwidgets] use '''incr Tcl''' * [ClassyTcl] - binary package. [ClassyTk] uses '''ClassyTcl''' * [stooop] - pure Tcl package, bundled with [Tcllib], [ActiveTcl] * [Snit's not incr Tcl] or '''snit''' - pure Tcl package, bundled with [Tcllib], [ActiveTcl] * [XOTcl] - binary package, bundled with [ActiveTcl] ** 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]: [obstcl]: Small Tcl object system package [obTcl]: A Tcl 7.[[45]] object and megawidget extension, supporting multiple inheritance, three new storage classes, and fully transparent Tk megawidgets. [Pool (Kupries)]: yet another OO Tcl-based system [scwoop]: Simple Composite Widget Object Oriented Pacakge [Snit's Not Incr Tcl]: a pure-Tcl object framework which relies on object composition and delegation rather than object inheritance [sntl]: Sam's (Non-Standard) Tcl Library [STERNO]: Simple Tcl Extra Really Nice Objects [stooop]: part of [tcllib]. Provides commands to extend Tcl in an object oriented manner. Meant to be as simple to use as possible. [LOST]: a reverse-engineered implementatin of Richard Suchenwirth's [Gadgets] [Tcl++]: A pure Tcl implementation of incr Tcl. [Tclpp]: 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) [Iliadtool2 Tea]: Follows the Java model, trying to implement the look of Java from a class definition perspective, yet remain syntactically consistent with Tcl. [TODL]: An easy way to build Tcl objects (to be used as an educational aid rather than a development tool) [XOTcl]: Extended OTcl - exotickle - is a value added replacement of the MIT OTcl object extension. In addition to all the OTcl. One of the more popular object systems for Tcl *** Prototype-Based *** [BOS]: [Poet]: Prototype Object Extension for Tcl. Features prototype-based inheritance, constrainst, and persistence. [Snit's Not Incr Tcl]: a pure-Tcl object framework which relies on object composition and delegation rather than object inheritance [framesets]: Frameset based OO implemention for Tcl. [theObjects]: Small prototype-oriented object system. [Yet another object system]: does everything with lists. [SDynObject]: a pure Tcl system that is very simple and extensible. [Procs as objects]: does it with default arguments to procs, instance variables might be kept in alias only. [TOE]: 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. [TWO]: Tcl With Objects. Author wrote it because I felt that existing object extensions to TCL either were so complex they were difficult to port and to debug, or they made member variable access unnecessarily complex *** Aspect-Oriented *** [tclaop]: Aspect Oriented Programming extension (experimental). Based on the good work of stefan Sinninge Tclpp (version 1.2, pure tcl script). *** Unsorted *** What: this Where: From the contact Description: An easy way to build Tcl objects. Contact: mailto:cball@etsd.ml.com (Charles Ballance) 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) ---- A lightly annotated index to most of the same packages appears at [http://phaseit.net/claird/comp.lang.tcl/ootcl.html]. ---- The community would benefit greatly from even the most rudimentary OO benchmarking project. [Miguel Sofer] points out that Doug Bagley's "Shootout" [http://www.bagley.org/~doug/shootout/] 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 [namespace]s with [inheritance] [http://groups.google.com/groups?selm=25de52c4.0108221036.3f6a84e8%40posting.google.com&rnum=1]. ---- 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, with'''out''' syntactic scaffolding. ---- See also: * [a case for oo in the core] * [A simple comparison of Tcl object extensions] * [advantages and disadvantages of oop] * [another minimal tcl object system (XOTcl like syntax)] * [cobj]. * [Dyso object system] * [Matt Newman's object system], * [Meta-object protocol] * [Object Instantiation Test] * [Object vs. Megawidget] * [objectwalker] * [Odys object system] * [oo killed my brother] * [oo libraries] * [oo2], * [oo] * [Self] * [simple class/object commands] * [Simple Closures and Objects], * [TCL Architecture of Objects], * [Thingy: a one-liner OO system], * [thoughts on implementing oo in tcl] * [thoughts on namespaces and oo] * [thoughts on oo, natural language, human thinking] * [transparent oo for tcl] * [UFO (yet another pure tcl OOS)], * [UPL: Command-Oriented & Object-Oriented Tcl/2] * [Yet another object system], * [skeleton oo] * [tiny oo with jim] * [ical oo] * [oo system for tcl9] * [tcl oo bench] * [oomk] * [oo method calls] benchmark * [ootcl] * [thingy oo with classes] * [Tcl_OO] by [Joe Mistachkin]. * [Tao] by [SDW] [Kristoffer Lawson] (aka [setok]) has made a package of his [Selfish] object system, done in pure Tcl. ---- See TIPs: * #6 [http://tip.tcl.tk/6] (failed), * #50 [http://tip.tcl.tk/50] (passed vote, but never implemented; see [Integrating Itcl into the Tcl core] for discussion) ** [DKF]: Was implemented in 8.6 on top of [TclOO]. * #257 [http://tip.tcl.tk/257], * #279 [http://tip.tcl.tk/279] for some of the history of proposed object orientation for Tcl. ---- See [thoughts on implementing OO in tcl]. <> Concept | Object Orientation | Arts and crafts of Tcl-Tk programming