Saturday, August 14, 2004

Extreme Late Binding and The Definition Of OOP

I found this over on comp.lang.smalltalk. It's a post by Omaha's very own Alan Wostenberg. We Smalltalkers sure do know how to kick a lot of booty. I also love the quote from Alan Kay at the bottom. Why can't the static dudes understand? SIMPLICITY and LATE BINDING is where it's at! Come feel the love with us! Anyway, without further delay:
    "Static typing prevents certain kinds of failures. Unfortunately, it
    also prevents certain kinds of successes." - Ned Batchelder, quoted by
    Peter Lund{1}

    I had one of these surprise successes today. Situation was: how to
    report progress to the interactive user of a very long running
    calculation in a remote image. I began by passing the remote calculator
    a value model
    remoteObject longCalculation: 0 asValue.
    The idea was the calculator's inner loop would periodically send #value:
    to the model with an update of % done:
    RemoteObject>>longCalculation: aModel
    1 to: 10 do: [:each | aModel value: (each / 10).
    (Delay forSeconds: 1) wait. ]

    So far so good. But the advantage of extreme late binding came when I
    changed my mind and decided to use a Block of arbitrary code to report
    status. Now it happens that Block also responds to #value: and so the
    client image can report status in a totally different way:
    remoteObject longCalculation: [:percent | Transcript show: percent

    Remote server doesn't know wether client is passing in a numeric
    ValueHolder or a Block -- it takes anything that responds to #value: .
    It stunned me and my teamates this worked! We're passing a block context
    in the client image across the ORB to the server, which evaluates it
    inside the client. This little block is far simpler than the distributed
    event-change notification mechanism!

    Question: Remote blocks work Distributed Smalltalk. Will they still work
    in OpenTalk?

    Anyway it was a nice late surprise. At compile time I thought I wanted a
    numeric ValueHolder, and later, during debug, I decided to use a block.
    (while in the debugger, 'natch). Extreme late binding is so liberating
    Alan Kay makes it part of his definition of OOP{2}

    "OOP to me means only messaging, local retention and protection and
    hiding of state-process, and extreme late-binding of all things. It
    can be done in Smalltalk and in LISP. There are possibly other
    systems in which this is possible, but I'm not aware of them"

    Alan Wostenberg, Omaha

No comments: