Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Mar 2002 02:34:02 +0000
From:      Tony Finch <dot@dotat.at>
To:        "Brian T. Schellenberger" <bts@babbleon.org>, Nate Williams <nate@yogotech.com>, Kenneth Culver <culverk@alpha.yumyumyum.org>
Cc:        Terry Lambert <tlambert2@mindspring.com>, "Steve B." <steveb99@earthlink.net>, "Eugene L. Vorokov" <vel@bugz.infotecs.ru>, freebsd-chat@FreeBSD.ORG
Subject:   Re: C vs C++
Message-ID:  <20020307023402.A19669@chiark.greenend.org.uk>
In-Reply-To: <20020306030145.01E6ABA03@i8k.babbleon.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Brian T.Schellenberger <bts@babbleon.org> 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 <dot@dotat.at>
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020307023402.A19669>