Newsgroups: comp.lang.smalltalk,comp.lang.c++,comp.lang.java,comp.object
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel-eecis!news.mathworks.com!newsfeed.internetmci.com!howland.reston.ans.net!blackbush.xlink.net!slsv6bt!news
From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763)
Subject: Re: Java vs. Smalltalk vs. C++ vs. OO COBOL
In-Reply-To: Tim Menzies's message of 27 Jun 1996 06:57:29 GMT
Message-ID: <KANZE.96Jun27144659@slsvgqt.lts.sel.alcatel.de>
Lines: 80
Sender: news@lts.sel.alcatel.de
Organization: GABI Software, Sarl.
References: <4qrjrl$e7s@piglet.cc.uic.edu> <4qs63q$13aa@piglet.cc.uic.edu>
	<4qsg8q$638@news.internetmci.com> <4qtbcp$jr9@mirv.unsw.edu.au>
Date: 27 Jun 1996 12:46:59 GMT
Xref: glinda.oz.cs.cmu.edu comp.lang.smalltalk:39955 comp.lang.c++:197153 comp.lang.java:64266 comp.object:51017

In article <4qtbcp$jr9@mirv.unsw.edu.au> Tim Menzies <timm> writes:

|> In article <4qsg8q$638@news.internetmci.com> jeffrey.langr@mci.com writes:
|> >In <4qs63q$13aa@piglet.cc.uic.edu>, dhanle2@icarus.cc.uic.edu (David James Hanley) writes:
|> >>	But consider all the serious flaws with smalltalk:
|> >>
|> >>	1)idiotic lack of static typing.
|> >>	2)lack of inheretence.
|> >>	3)poor parameter passing mechanism.
|> >>	4) etc,etc...
|> >>	:)
|> >
|> >1. not a flaw. this point is debatable based on your preferences. I'd rather have
|> >   the dynamic typing that allows for things such as heterogeneous lists...
|> >2. lack of inheritance?  perhaps you mean *multiple* inheritance, which even
|> >   many of the best C++ developers say not to use unless you absolutely have
|> >   to

|> yes. studies with large c++ libraries show that the average parents per class
|> is 0.49; i.e. c++ programmers do not make extesnive use of inheritance
|> in general and multiple inheritance in particular.

I suspect that most large C++ libraries are basic class libraries, more
concerned with extending the types (in the classical sense) available
to the implementation.  As such, they will typically not be
particularly OO-oriented, any more than is int or double.

If you look at large applications, on the other hand, the statistics
would no doubt be different.  If I look at the application I am
currently working on, for example, the average number of parents for
classes in the application domain would be somewhere between 2 and 3,
whereas the average number of parents in the basic classes used to
implement the application would be 0.

|> also, if we look at the design patterns book, we see that they recommend
|> more aggregation than inheritance; i.e. oo design theoriests tell us that 
|> the key to intricate object behaviour is not via extensive use
|> of inheritance.

As is often pointed out, multiple inheritance (in C++) may be used for
two distinct purposes: interface and implementation.  Since each
individual pattern in the design patters book is concerned with a
single interface, it is understandable that there are no instances of
multiple inheritance of an interface.

Concerning multiple inheritance of implementation, in general, I would
also find aggregation preferrable.  Still, however, it is worth looking
at some of the examples in Barton and Nackman; they use multiple
inheritance extensively, and a lot of it is for implementation.

Concerning multiple inheritance of interface, it is, of course, only
necessary if the language requires declaring the interface, and
enforces it with strict static type checking.  Which is, of course, the
case of C++, but not of Smalltalk.  Even in the case of strict type
checking, multiple inheritance of interface can be simulated with
delegation.  This is, however, requires some programmer effort, and a
lot of programmer effort if there is no garbage collection and generic
classes.  I would not like to have to do it in C++, although it would
not be anywhere near as difficult in, say, Modula-3.

I would hope that, even though Smalltalk does not support (nor need)
multiple inheritance at the language level, most Smalltalk programmers
will define rigorous interfaces, and document which interfaces a class
implements.  (In many ways, I find that the Smalltalk type system
resembles that of C++ templates.  When I define a template over class
X, I will specify that this class must support operations o, p and q.
If it doesn't, the compiler will probably complain when it tries to
instantiate the template.  In Smalltalk, a similar effect takes place
at runtime.  If I define a method taking a parameter, I will require
that the object passed at runtime support certain operations; if it
doesn't, I will get a runtime error.  In both cases, the instantiation
class / object passed as parameter must comply to a certain interface.
In neither case is there any way within the language to specify and
enforce this interface.)
-- 
James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils, tudes et ralisations en logiciel orient objet --
                -- A la recherche d'une activit dans une region francophone

