Re: Classes and the Production of Objects
Re: Classes and the Production of Objects
- Subject: Re: Classes and the Production of Objects
- From: email@hidden (Andrew Demkin)
- Date: Mon, 12 Aug 2002 00:05:26 -0700
Chris,
Your posting to the cocoa-dev list caught my attention. I thought you made
several good points, but I also felt compelled to share some slightly
different points of view. I recognize that this discussion is off-topic for
the list, so I'll try to limit my comments to this one reply. I hope you
find it worthwhile.
=-=-=-=-=-=-=-=
1) Is C++ a true OO language?
Objective-C does have better support than C++ for message forwarding and
delegation, but I don't think it's fair to characterize C++ as a less
"true" object-oriented language. Smalltalk has garbage collection and block
closures, but Objective-C does not. Is Objective-C therefore a less "true"
OOPL than Smalltalk?
=-=-=-=-=-=-=-=
2) STL is too "low-level" and doesn't properly use inheritance
While the common interfaces for STL containers are not expressed via
inheritance, it doesn't mean such interfaces don't exist. If they didn't
exist, the definition of standard algorithms would not be possible.
One reason that similar container classes are "not always direct
substitutes for each other" is their differing performance characteristics.
For example, inserting an item to the front of a list is O(1); doing the
same to a vector is O(N). Thus, std::list defines push_front(), but
std::vector does not. This approach is not an oversight, but rather a
deliberate design decision that can protect a developer from making an
inadvertent mistake.
FWIW, one could present similar straw man criticisms of the Cocoa
collections. Every collection type shares some behavior, yet there is no
NSCollection base class to capture this notion. Cocoa also fails to offer a
linked list or balanced tree. I don't think these are big issues, but you
know what they say about throwing stones in glass houses.
=-=-=-=-=-=-=-=
3) C++ RTTI is "pitiful"
Yes, it would be nice to get some additional dynamism/reflection in C++. As
I see it, the current standard is version 1.0 and a great many projects
just don't require these features, so one can at least rationalize their
absence. However, I agree that some projects can be done much more easily
with these features and I hope that we'll one day see them added.
=-=-=-=-=-=-=-=
4) Fundamentally, C++ takes too low-level a view of the world
And arguably Objective-C does the same. Let's have everyone learn Smalltalk
and then have this discussion again ;-)
=-=-=-=-=-=-=-=
5) C++ is "flawed"
Perhaps, but one could also say that Objective-C is flawed because it has
- "weak" type-checking,
- not enough control over space versus performance tradeoffs,
- no language-supported exception handling,
- no static binding for private methods,
- no automatic memory management / garbage collection
...etc...
=-=-=-=-=-=-=-=
>
(I personally believe that if C++ was taught using proper
>
object-oriented terminology, not only would Smalltalk and Objective-C
>
be much easier to learn for C++ programmers, but that C++ programmers
>
would write better code because they'd be used to thinking just
>
slightly more abstractly than they tend to now.)
Learning more abstract concepts is always a good thing, but it works both
ways. There are features of C++ that make it more desirable than
Objective-C. There are features of Obejctive-C that make it more desirable
than C++.
I'd actually be quite surprised to learn that many C++ programmers have a
difficult time learning Objective-C or Smalltalk. I'd find it more likely
that such developers just don't see the need for using these languages.
Some might be short-sighted, others are not.
=-=-=-=-=-=-=-=
>
The Objective-C way of doing things is actually a very close match
>
for the abstract concepts of object-oriented programming;
>
object-oriented programming is defined as "programming by sending
>
messages to objects" and the term was created by Alan Kay to describe
>
Smalltalk, a language he (and his team at Xerox PARC) invented. It's
>
C++ that doesn't exactly match these abstract concepts even though it
>
calls itself object-oriented.
I think our understanding of OO languages has evolved since that
definition. There are a variety of languages that offer different features
and capabilities than Smalltalk, yet they're all considered
object-oriented.
If you haven't already seen it, you might want to check-out Kim Bruce's
work (
http://www.cs.williams.edu/~kim/), including his recent book titled
"Foundations of Object Oriented Languages: Types and Semantics". The field
is definitely still evolving.
I do agree with your general assertion that C++ is a (sometimes overly)
complicated language that often obscures some simple and powerful concepts.
Never the less, I think it also deserves some respect for advancing the
state of OO programming.
Perhaps the objective we're all seeking is how to quickly and easily build
reliable software without paying too much in costs of performance and
maintenance. C++ and Objective-C attack the problem from different angles,
and neither is perfect nor complete. Over time I suspect and hope we'll see
the emergence of new solutions that result from some degree of "cross
pollenation".
Cheers,
Andrew.
"To discover new lands one must be willing to lose sight of the shore"
- Andre Gide
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.