Relation Oriented Programming with Raloo

Relation Oriented Programming Tcl2008 talk by Andrew Mangogna.

Overview:

  • Raloo is a Tcl script package that implements a form of Relation Oriented Programming
  • Raloo combines: TclRAL (relation values, relvars, integrity, contrainst, relational algebra operations)
  • TclOO combines: classes, objects, methods, OO building blocks
  • Raloo emphasizes: strong data structuring via relations; event driven state machines for sequencing processes; Tcl code for algorithmic processing; domains for packaging subject matters

Raloo classes are Tcloo classes with object data stored in a TclRAL relvar. "A match made in heaven, or a marriage made in hell? You decide at the end of the talk" Raloo objects refernce tuples in the class relvar. The relationships are TclRAL relvar constraints. Referential integrity is checked automatically at appropriate time for the entire class model, without you having to write any code. Raloo supports associating a state machine with a class for async processing. Processing is accompanied by writing ordinary Tcl code.

Three projections of a Raloo solution:

  • Relationally normalized class model: classes, relationships, integrity constraints.
  • Finite state machine model of asynchronous processing: Moore machine for active classes, state machine dispatch uses Tcl event loop.
  • Object oriented Tcl code for processing: methods for navigating the class model, methods for generating state machine events.

In Tk event loop is already running; in tclsh Raloo programs have the flavor of a Tk application.

One Button Microwave

  • Press button with door closed runs for 1 minute
  • Press button while running adds a minute
  • opening the door while running stops the oven and resets the time
  • Light must be on when the door is open or the microwave tube is on
  • Microwave tube may only be on when the door is closed

[Showed a graphical representation of the above.] All ovens have a lamp and a tube. No tubes or lamps exist without an oven. Showed example code implementing an Oven class. Code to define attributes, relationships, Code to run at lifecycle transitions. This example (documentation, code) in the Tcl Raloo package.

Question from the chat: can you have null attributes? Answer: Not really since Tcl does not have a concept of null, but if there ever were a change so that there was a "null" Tcl_Obj and expr were modified to support three-value logic, then everything should just work.

[Ran the one-button microwave demo]

The ideas behind Raloo are not new or original. Three projections of the problem space: static structure encoded as a relation class model; dynamics encoded as a state machine; algorithms written in code; capture program structure declaratively. Raloo execution semantics match those of Executable UML ("not your grandmother's UML"). Raloo combines the foundations provided by TclRAL (a complete relational algebra) and TclOO (set of object oriented building blocks).

Download from http://sourceforge.net/projects/tclral

Requires TclOO (0.5.1), Tcl 8.5 (or better presumably; hasn't personally had time to try with alpha versions of 8.6 yet). "Read the paper! Please." More examples, explanation and references there.

 Q: How many microwaves can you run?
 A: I only have room for 12-15 on my screen at a time (Linux on celeron)

 Q: Limits on the # of rows?
 A: Just a function of memory.  Has a colleague who has serialized 95 megs worth of TclRAL relations.