Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!gatech!hubcap!ncrcae!ncr-sd!hp-sdd!ucsdhub!esosun!seismo!uunet!mcvax!inria!crin!tombre From: tombre@crin.UUCP Newsgroups: comp.lang.misc,comp.lang.smalltalk,comp.lang.c++ Subject: Re: C++ vs Objective-C Message-ID: <350@crin.crin.fr> Date: Wed, 30-Sep-87 06:22:02 EDT Article-I.D.: crin.350 Posted: Wed Sep 30 06:22:02 1987 Date-Received: Sat, 3-Oct-87 12:07:00 EDT References: <3405@ece-csc.UUCP> <638@its63b.ed.ac.uk> <305@ucdavis.ucdavis.edu> Reply-To: tombre@crin.crin.fr (Karl Tombre) Organization: CRIN - INRIA Lorraine, Nancy, France Lines: 48 Xref: utgpu comp.lang.misc:677 comp.lang.smalltalk:323 comp.lang.c++:436 In article <305@ucdavis.ucdavis.edu> windley@iris.ucdavis.edu (Phil Windley) writes: >In article <275@nih-csl.UUCP> keith@nih-csl.UUCP (keith gorlen) writes: >> since C++ is strongly typed, > >Can C++ (or any of the others in this contest) be weakly typed as well >as strongly typed? Does the programmer have any control over this? >Any advantages to letting the programmer have a choice? Just curious. > Isn't the difference more between static and dynamic typing than between weak and strong typing ? Admitted, C is not very strongly typed. But when you compare Objective-C and C++, the difference is elsewhere. In C++, the typing is static, that is you check the validity of your expressions at compilation time, and if necessary the compiler does automatic type casting (C++ is VERY good at that!!). In Objective-C, at least in the "object environment", the typing is completely dynamic : at compile time you only translate a message [object message] into a call to the _msg() function, which at run time searches for the right method in the class tables. This provides dynamic binding in Objective-C. In C++, you have to declare a function as virtual to get a limited dynamic binding. What is better? It depends what you do. Objective-C will give you a less rigid environment, but you lose strictness and a bit efficiency. In addition, if your concern is to write reliable code (in the sofware engineering sense), you might want to have most problems detected at compile time; then C++ is for you. If you want to write a prototype without knowing exactly all the aspects of the final product, but with more efficiency than Smalltalk, go for Objective-C. The debate is one between two philosophies in object-oriented programming: the Smalltalk approach and the Simula (or C++) approach. To put it schematically, and not very strictly (please do not flame me on this, I'm just having a little fun generalizing), we can say that: In Smalltalk or Objective-C everything which is not explicitely prohibited is allowed. In Simula-67 or C++ everything which is not explicitely authorized (or let us say planned in advance) is prohibited. Any comments? --- 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 83.91.21.25