Article View: comp.lang.objective-c
Article #241Re: Objective C vs C++
From: Mark Carroll
Date: Wed, 20 Feb 1991 15:35
Date: Wed, 20 Feb 1991 15:35
87 lines
4009 bytes
4009 bytes
In article <40804@genrad.UUCP> dxb@genrad.com (Daniel A. Burkhard) writes:
>In article <44957@nigel.ee.udel.edu>, carroll@cis.udel.edu (Mark Carroll) writes:
]
]] ... stuff deleted
]
]] C++ is a systems language. It's very low level, very fast, etc. It's
]] optimized towards very low level programming. It's not very good
]] at abstraction. It's completely impossible to implement a class in
]] a way where a user cannot change the private parts of the class, or
]] alter the class declaration. ............
]
]How so ?? C++ gives you member access control private (default), public, and
]protected. A user has no direct access to private members, i.e private
]members can only be changed thru the public interface of a class.
][ Of course these rules can always be violated in any language that supports
] access to raw memory ...]
]
I'm not talking about during execution; what I mean is that the .h
file declaring the class MUST be accessible to and alterable by the
user. A user can muck about inside of the declarations of any class
which he is permitted to use. In Objective-C, that can be prevented.
(The private declarations are not necessary to use a class.)
]] C++ is almost completely statically bound;
]] dynamic binding only comes into play when you start using virtual
]] function, and only functions tagged virtual can be rewritten in your
]] subclasses.
]
]I'm not exactely sure what you mean by "rewritten", but of course something
]like
]
]class foo
] {
] int a;
] public:
] foo(int aa=1) { a = aa;}
] int geta() { return a;}
] };
]
]class bar: public foo
] {
] int b;
] public:
] bar(int bb=2) { b =bb; }
] int geta() { return b;}
] };
]
]is perfectly legal in C++ [note: no "virtual" here].
]
True. But if I pass an instance of class bar to a function expecting an
instance of class foo, and inside the function, I call the geta(), I'll
get foo's geta(), not bar's. If the only OO background you have is C++,
you'll just say, "Oh. But that's where you use virtual functions". But
in "traditional" object-oriented design, ALL functions are "virtual". I
should be able to reimplement ANY function in a subclass, and have it
always get called correctly, whether the original author thought that I'd
want to or not.
C++ makes the assumption that the original author is fully aware of
EVERYTHING that the users of a class might want to do with it in
the future; that's an acceptable assumption, since it's so easy to
go in, and change the class declarations if he was wrong. In Objective-C,
no such assumption is made, and it is not necessary to ever alter the
class declarations in order to be able to make use of the class.
]] .. stuff deleted
]] ..................... Also, in
]] C++, it is possible to distribute object-code for classes, without the
]] corresponding source. You can present objects which the user can make
]] full use of, but cannot alter without implementing a subclass. The private
]] parts of one of these classes can NEVER be changed by their users.
]
]This seems to be a contradiction to your first point.
Sorry. Typo. ^C++^Objective-C.
]-- dan
<MC>
--
---------------------- Mark Craig Carroll: <MC> ------------------------
------ U of Del. Grad Student in CIS ------ EE/CIS LabStaff Hacker ------
-- Resident Wierdo @ 105 E Cleveland Ave, Newark DE - carroll@udel.edu --
---------------------- Shalom Achshav - Peace NOW! ----------------------
Technical Details
Message-ID:
<45238@nigel.ee.udel.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!udel!cis.udel.eduReferences:
<60377@eerie.acsu.Buffalo.EDU> <44957@nigel.ee.udel.edu> <40804@genrad.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!udel!cis.udel.edu From: carroll@cis.udel.edu (Mark Carroll) Newsgroups: comp.lang.objective-c Subject: Re: Objective C vs C++ Keywords: why Message-ID: <45238@nigel.ee.udel.edu> Date: 20 Feb 91 15:35:05 GMT References: <60377@eerie.acsu.Buffalo.EDU> <44957@nigel.ee.udel.edu> <40804@genrad.UUCP> Sender: usenet@ee.udel.edu Organization: University of Delaware Lines: 87 Nntp-Posting-Host: apollo.cis.udel.edu