Re: Cocoa from C++ (dont want to mix it)
Re: Cocoa from C++ (dont want to mix it)
- Subject: Re: Cocoa from C++ (dont want to mix it)
- From: Guy English <email@hidden>
- Date: Fri, 11 Mar 2005 10:16:59 -0500
Dominik <email@hidden> wrote:
> > What is it you actually want to do though? Why is the existing
> > Objective-C++ not suitable? Is it just a language preference kind of
> > thing?
> Well, a friend asked why C++ is not used instead of learning a new
> language.
> I couldnt give him a sufficient answer
Well C++ has problems that become really vexing when you're writing an
OS toolkit. There was no standard ABI at the time OpenStep was
developed which meant that the vtables generated by different
compilers ( and even different versions of the same compiler ) weren't
compatible. So you couldn't link to libs compiled with a different
compiler. Also C++ suffers from the fragile base class problem. What
that means is that if I have a C++ object, link it to a bunch of apps,
then in a subsequent OS update need to change it all those apps need
to be rebuilt because their base class has changed. So adding a new
virtual method to the base Object class would bust everybodies apps.
There are work arounds - like reserving a bunch of slots in the vtable
- but it's not really elegant. It's worth noting that the big C++ OS
projects have all failed - BeOS suffered from the fragile base class
thing to a certain degree and Pink / Taligent died on the vine. IBM
and Apples SOM ( of which COM is a sibling/clone ) tired to address
this issue by defining interface in a language independent manner. SOM
worked well enough in OS/2 ( and was the foundation of the excellent
Workspace Shell ) and COM has, obviously, taken MS pretty far. The
basic problem stems from the compile time OO model that C++ uses. It's
ironic that one of the reasons C++ was adopted over other OO languages
was that it was seen to be more efficient but in the end needed lots
of support built around it to work usefully in a more dynamic
environment.
It's no accident that OS framework stuff is now all moving to much
more dynamic languages. Microsofts C# has the runtime flexibility to
properly support a decent framework. Java offers a similar model.
Objective-C has been dynamic since it's inception and in many ways the
rest of the industry is catching up to its simplicity. Gems like
Interface Builder, Distributed Objects, the delegate / data source
pattern and Cocoa bindings are all based on the fundamental dynamisim
of the Objective-C runtime.
So the short answer to why they don't just use "standard" C++ is that
it's just not suitable to the task. Any modern framework is going
require you to learn a new language, be it C#, Java or Objective-C.
It's just that OpenStep has been modern for about 15 years now.
Take care,
Guy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden