From owner-freebsd-chat Wed Mar 6 18:34:50 2002 Delivered-To: freebsd-chat@freebsd.org Received: from chiark.greenend.org.uk (chiark.greenend.org.uk [212.22.195.2]) by hub.freebsd.org (Postfix) with ESMTP id CFACC37B416 for ; Wed, 6 Mar 2002 18:34:46 -0800 (PST) Received: from fanf by chiark.greenend.org.uk with local (Exim 3.12 #1) id 16injG-0005dN-00 (Debian); Thu, 07 Mar 2002 02:34:02 +0000 Date: Thu, 7 Mar 2002 02:34:02 +0000 From: Tony Finch To: "Brian T. Schellenberger" , Nate Williams , Kenneth Culver Cc: Terry Lambert , "Steve B." , "Eugene L. Vorokov" , freebsd-chat@FreeBSD.ORG Subject: Re: C vs C++ Message-ID: <20020307023402.A19669@chiark.greenend.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020306030145.01E6ABA03@i8k.babbleon.org> Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Brian T.Schellenberger wrote: > > Objective C, for exmaple, is a much better C-based OO language > I wouldn't recommend C++ to anybody for anything myself. While I agree with you that C++ is evil incarnate, I don't have such a high opinion of Objective-C, which I think gains its reputation of being "proper OO for C" by being a straight copy of Smalltalk, without any regard for whether this makes sense in the context of C. In particular it completely fucks up the syntax of the language -- although it does manage to avoid braindamage like C++'s angle brackets for templates, but this is more by luck than by design since Smalltalk doesn't use angle brackets. I'm also rather leery of the semantics of the "id" type, especially when you look at how it interacts with Objective-C's facilities for sending generic messages to objects by slapping together a selector chosen at run-time with a load of arguments. Lots of opportunities for undefined behaviour there. In addition to this, Objective-C inherits some of Smalltalk's mistakes. The first problem is that subclasses inherit the instance variables of their superclass without namespace protection, which violates encapsulation. There is a work-around for this in Objective-C similar to C++'s private/public/protected labels, but the problem causes a secondary symptom which is more damaging. Objective-C is designed to allow classes to be added to a running program at run-time, but because of the tight coupling of a class to its superclass via the inheritance of instance variables, the whole of a program including its dynamic components must be compiled against the same sources -- the addition of an instance variable to any class breaks binary compatibility with all of its subclasses. The other problem is less severe: Smalltalk's and Objective-C's idea of the metaclass is only half-thought-through, leaving metaclasses as some kind of shadowy magic hiding behind their classes, when they would be much better of as more first-class entities. Similarly, although there is some provision for tweaking the object model, it is at the level of fiddling the implementation rather than being a proper API. Common Lisp's Object System with its metaobject protocol is much better in both of these respects. Tony. -- f.a.n.finch BISCAY: NORTHWESTERLY 4 OR 5 BECOMING VARIABLE 3. OCCASIONAL DRIZZLE. MODERATE, OCCASIONALLY POOR IN NORTH. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message