Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!gatech!newsxfer.itd.umich.edu!ncar!uchinews!news
From: kit@delphi.bsd.uchicago.edu (Kit Transue)
Subject: Re: What are the differences between C++ and smalltalk?
Message-ID: <1994Nov11.225942.3367@midway.uchicago.edu>
Sender: news@uchinews.uchicago.edu (News System)
Organization: University of Chicago -- Academic Information Technologies
References: <1994Nov10.160811.13092@arbi.Informatik.Uni-Oldenburg.DE>
Date: Fri, 11 Nov 1994 22:59:42 GMT
Lines: 65

In article <1994Nov10.160811.13092@arbi.Informatik.Uni-Oldenburg.DE>  
Roland.Radtke@arbi.informatik.uni-oldenburg.de (Roland Radtke) writes:
> Hi.
> 
>   I am working on a paper describing a C++ Tool with roots in
> Smalltalk. The folks who programmed it ported a lot of the
> methods of the Object superclass to C++. 
> 
>   I want to tell my audience a bit about (1) why C++ was chosen
> as implementation language (efficiency --- and I pray that this
> won't instigate yet another flamewar) and (2) which features of
> smalltalk were copied.
> 
>   In order to familiarize myself a bit with Smalltalk, I ftp'ed
> the GNU Smalltalk version and the Smalltalk.FAQ. Yet, I have been
> unable to ascertain precisely which differences there are (For 
> instance: is Smalltalk capable of multiple inheritance? Every bit 
> of information I have seen seems to indicate that, no,
> this is not the case. The C++-Smalltalk Objectclass interface, however,
> supports MI.)
> 
>   So, if anybody has a nice, comprehensive table comparing
> Smalltalk to C++, I would be delighted. 
> 
> Thanks in advance,
> Roland.

[In a C++ programmer's humble opinion:]

Briefly--there's obviously more than what I can throw together in a few  
minutes:

The big difference between C++ and Smalltalk is the notion of type.  In  
Smalltalk, a type may be defined as implementing a certain message set  
(the reciever object doesn't throw a "does not understand" exception when  
told to do something).  In C++, type is intimately related to the public  
class hierarchy: only those objects that are of a class or its public  
descendants are able to respond to messages intended for the base class  
(the intended class becomes part of the message signature).

This difference has several major implications.  First, it means that C++  
objects if they want to behave like two different classes must be  
multiply-derived from those classes (in Smalltalk, the object must only  
implement messages with the same names as those in the different classes).   
MI is necessary in C++; optional in Smalltalk, although IMHO it's a sound  
abstraction mechanism--giving C++ a bit of an edge in closely mapping to  
problem analysis.  Second, C++ provides compile-time typing (since  
membership in the class hierarchy is the same as type, and is readily  
available--in fact, required).  Compile-time typing is seen by this C++  
programmer as a mechanism for reducing some kinds of errors.  In  
Smalltalk, I find myself getting lost in lots of message forwarding, and  
am unable to figure out what class the message got forwarded to.   
(Smalltalk programmers might argue that it's not of interest what class  
actually got the message, but the use of abstract base classes to define  
types is a useful C++ idiom.  Much like Objective C's protocol....)

There are other less academic but as-important differences: C++ being  
compiled gives it a speed advantage, although good garbage collection in  
Smalltalk can be more efficient than C++'s often intensive new/delete  
activity.  Garbage collection probably makes for easier (safer, more  
productive) programming.  And Smalltalk makes for a very nice development  
environment.

hope this is of interest
kit transue
