[comp.lang.misc] OOP, Dynamic binding, and Type checking

rentsch@unc.UUCP (01/30/87)

In article <786@watmum.UUCP> gvcormack@watmum.UUCP (Gordon V. Cormack) writes:
>>> [Original article]
> > > Object-oriented programming is a religion that is currently in vogue.
> > > It adds little to the original class ideas of Simula 67, and the
> > > abstract data type ideas of Clu (which was inspired by Simula 67).
> > >
> > > Really the only thing that Smalltalk and its imitators
> > > add is dynamic procedure binding and dynamic type checking, which I 
> > > regard as highly undesirable.

>> [My response]
> > Dynamic binding yields considerable advantages over Simula,
> > including more polymorphic procedures and incremental compilation.
> > (Those of you out there who have used Smalltalk and/or Lisp systems
> > know what I'm talking about.)  Basically, the only reason *not* to
> > have dynamic binding is the belief that "it costs too much".  With
> > all the work that has been (successfully) done at making that fast
> > (method caches, class guessing, etc.) I hope we have put THAT myth
> > to bed.  Method lookup consumes not very much (I remember it as 10%)
> > of Smalltalk execution time.  10% is a very small price to pay for
> > the benefits of being able to recompile and relink any procedure into
> > a running system (~1.5 MB source code) in only a few seconds!

[Article replied to prefaced by '> ']
> 1.  The original point is that O-O adds nothing new.  Certainly 
>     dynamic binding and polymorphism weren't new in O-O.

Second sentence is right, first is wrong.  The original point was
that OOP doesn't add much to Simula, to which I responded that
dynamic binding adds quite a bit to simula.  I concede that dynamic
binding and polymorphism were not introduced by OOP (I even mentioned
LISP, for goodness sakes!), but that is beside the point.  [Side
comment -- OOP preceded CLU, not the other way around as some people
might have inferred from the original posting.] 

> 2.  It is highly questionable that dynamic binding and static type
>     checking are compatible.  For a turing-machine equivalent language,
>     it is undecidable what messages are sent to what objects.

It is in general true that which messages are sent is undecideable.
Even so, dynamicly bound languages can be type-checked, the same way
that other languages can -- by adding type declarations.

> 3.  Because of 2., there is a great deal to be gained by static
>     binding/ type checking - namely some verification that the 
>     program does something reasonable.

You are confusing the two -- dynamicly bound procedure calls can
still be type checked.  Such a system would retain the advantages of
dynamic binding (incremental compilation, instantaneous link) while
allowing the safety and early error catching of type checking.

> 4.  Even Lisp programmers, etc., are discovering types - read 
>     Milner's paper on ML.

Lisp people need types more than Smalltalk people because it's easier
in Lisp to make the kind of errors that type checking catches.  (If
you meant instead that Lisp programmers, etc., are discovering the
advantages of "type modules", i.e., classes, I can only say its about
time!  And, I have read Milner's paper -- important work, but largely
irrelevant to the question of dynamic binding.)  

> 5.  It is true that most strongly typed languages are straightjackets;
>     some have great expressive power, flexibility, and polymorphism.

I have never seen a strongly typed language which allows as much
polymorphism as Smalltalk.  (Other non-strongly-typed languages are
as polymorphic as Smalltalk.)  Whether this expressive power is akin
to the "expressive power" of GOTO statements, and best done without,
is possible -- although, until we see the analog of the "structure
theorem" for typed languages, I remain skeptical.

> 6.  Class hierarchies (as in Simula67) give polymorphism without
>     resorting to dynamic anything.

First, although subclasses give some polymorphism, they don't give
as much polymorphism (or even as much useful polymorphism) as
does Smalltalk.  It takes effort to bend the Simula type-system to
the OOP point of view, and even then it doesn't do as much as
Smalltalk.
    Second, check you Simula manual again.  Parameters to virtual
procedures are checked at runtime.  This is dynamic something, but
sadly it's the wrong something (i.e., dynamic type checking but not
dynamic binding).  [Also, some would argue that virtual procedures
are a weak form of dynamic binding.  But that's neither here nor
there.]

> 7.  I still have not seen a satisfactory definition of O-O.  I am not
>     at all sure that one exists.  I think it *is* essentially the
>     Simula programming methodology invented 20 years ago by Dahl
>     et al.

You haven't seen one because a technical, formal definition of OOP
does not (yet?) exist, any more than a technical, formal definition
of 'structured programming' does not exist.  [I do not share the
viewpoint that SP is "programming without GOTO's", or "programming
using only IF's, WHILE's, and SEQUENCE".  These are definitions,
certainly, but not useful ones.]  Like structured programming, OOP is
a methodology, or alternatively a way of thinking when writing
programs.  In such cases it is difficult to give a definition which
captures the essence of the term in question.  (How long did it take
to give a formal definition to "mass", "momentum", "force",
"energy"?)
    I believe that OOP is at the extreme end of a spectrum, and that the
Simula methodology, while close to the same end, still differs in an
important and fundamental way.  I can only recommend using a
Smalltalk system for a while (and writing code in it) as one way to
see the difference.  

btw, I appreciated the manner of the posting, even though I disagree
with most of the points made.  So, please don't take my comments
personally, Gordon, they are not intended that way.

cheers,

Tim