Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!mcvax!inria!crin!tombre From: tombre@crin.crin.fr (Karl Tombre) Newsgroups: comp.lang.misc,comp.lang.smalltalk,comp.lang.c++ Subject: Re: C++ vs Objective-C Message-ID: <338@crin.crin.fr> Date: Tue, 22-Sep-87 04:42:21 EDT Article-I.D.: crin.338 Posted: Tue Sep 22 04:42:21 1987 Date-Received: Sat, 26-Sep-87 04:17:53 EDT References: <3405@ece-csc.UUCP> <638@its63b.ed.ac.uk> <1811@watcgl.waterloo.edu> Reply-To: tombre@crin.crin.fr (Karl Tombre) Organization: CRIN - INRIA Lorraine, Nancy, France Lines: 52 Xref: mnetor comp.lang.misc:681 comp.lang.smalltalk:332 comp.lang.c++:450 I don't think it's so easy to say which language is "better". Neither do I think that one is more "unified" than the other. What was said about Objective-C (dealing with 2 universes) may be true, but 1) it depends on the way you program. If it is important for you to use strings as objects, use the Smalltalk-80 like class for strings. If you occasionnaly want to printf() something, use a C string. In fact, you can consider it as two layers. You are not compelled to use the C constructs, but they may be useful for efficiency. 2) the same can be said of C++. It is not more "unified" than Objective-C. You also retain full compatibility with C, you can use structs instead of classes, the privacy mechanism is sometimes a bit confusing because of the C layer, ... In fact, C++ and Objective-C are good examples for two main directions in Object-Oriented Programming : the "norwegian" school and the Smalltalk school. C++ is in the "norwegian" family, that is a successor of Simula-67, the first object-oriented language. As Simula, it has static typing and restricted dynamic binding by ways of virtual functions. As Bjarne Stroustrup points out in a paper (What is Object-Oriented Programming), a C++ (or Simula-67) class is an exact specification, whereas a Smalltalk class is a minimal specification. C++ adds some new features to Simula-67 : private data, friend functions (which are not necessary in Simula-67 where the data are not private), operator overloading, constructors and destructors... But basically it remains in the same family. Among other things, the main entity is the class, not the object. Inside a class, there is no privacy : two instances of the same class have access two each other's private fields. Objective-C is a child of Smalltalk-80. It implements dynamic typing and binding by means of run-time message transmission. The individual object is completely private : you are only allowed to access it's fields through access methods, and hence a message. There are clear analogies between the factory methods and the metaclass methods in Smalltalk. At run-time, the factory is a special object which implements the class in a way. But you can also use at any moment the C layer, for instance when writing a method for a class. Thus, you have direct access to the private data of the current object, and hence you can write efficient methods. My feeling : it is interesting to compare the two languages, but difficult to say which is "better", as both of them implement well the principles of one of the OOP "schools". The comparison is more between those schools than between the 2 languages. --- Karl Tombre @ CRIN (Centre de Recherche en Informatique de Nancy) EMAIL : tombre@crin.crin.fr -- tombre@crin.UUCP POST : Karl Tombre, CRIN, B.P. 239, 54506 VANDOEUVRE CEDEX, France PHONE : +33 83e the ce t