Messaging vs. subroutines

Joachim Durchholz joachim.durchholz at munich.netsurf.de
Wed May 19 20:09:25 UTC 1999


Dwight Hughes wrote:
> 
> > From: Joachim Durchholz <joachim.durchholz at munich.netsurf.de>
> > Well, my idea of OO starts with polymorphism. Late binding aka
> > dynamic binding aka virtual method dispatch aka current Smalltalk-80
> > message send is the tool that implements that, so my position isn't
> > that far from the Smalltalk one.
> >
> > I don't see the reasoning behind Alan's claims. Is there a place
> > where he goes into more detail on *why* he thinks that messaging is
> > central?
> 
> I don't know of any specific published work on this, but as others
> have noted: you _could_ just take Alan's word on this. :-)

As you may have noted, I'm not very good at taking anybody's words on
anything :))

> [Interesting bits on the history of Smalltalk snipped]

As far as I understand this, the mental model of messages being sent
about is the initial point and the ST-80 implementation is one (rather
limited) way of going about it, and future Smalltalks will (or should)
have a more general approach about what messages gets sent when or to
whom.

I can appreciate that approach, but I think it's misleading.
Unrestricted message sending can lead to a spaghetti of control flow,
just as unrestricted gotos. Message sends in themselves aren't that
important; the structure of the message flow is the essential thing. And
structure means restrictions; without restrictions, there is no
structure, and everything becomes spaghetti. Now, discussing what
restrictions would be useful, *that* would be an interesting debate. My
personal view would be that the synchronous model is a very useful way
of restricting message sends, witnessed by the long ST-80 tradition and
the fact that the overwhelming majority of people outside of the
Smalltalk community seem to be quite at ease with the subroutine model.
(Of course such arguments aren't conclusive; they are just hints and can
be attacked on various grounds. I'm always open to new insights in this
area.)

On terminology:
People on this list are programming in ST-80. ST-80 has a synchronous
messaging model, which I still think has enough similarities with
standard subroutine calls that it would make sense to call them just
that. Some people on this list have violently disagreed; well, what's
the best and most fitting terminology is a rather pointless debate,
because it's finally a rather subjective thing.

On mental models:
I think the message model of Smalltalk is important. It certainly opened
a new way of thinking about programs for me when I read first about it.
However, it is just one model; I have found other models just as useful.
One model is recursion (even though I haven't written a single recursive
function in the last decade). Another model is that of an object as an
abstract machine, with commands (things that make the machine buzz and
whirr and change its internal state) and queries (indicator lamps and
scales on the outside of the object); in that context, commands and
queries are just simple subroutines.
I wouldn't want to miss *any* of these models. Sometimes the messaging
model gives the best results, sometimes recursion, sometimes the
abstract machine, sometimes even yet another model. Often I'm pursuing
several models in parallel, to see which one will take me farthest.
I fear that considering everything as just a message send (with an
obligatory answer in ST-80) is restrictive in its own way, even if one
can do highly beautiful, elegant, and useful things with it. The more
models you know and use, the more approaches you will see; and more
often than not only a combination of models will yield an architecture
that no model alone would provide the insight for.

Regards,
Joachim
-- 
Please don't send unsolicited ads.





More information about the Squeak-dev mailing list