[comp.sys.mac.programmer] Object Oriented C for the Mac

adams.e@oxy.edu (Erik Adams) (07/21/89)

Pardon my ignorance, but what are the primary differences between
object-oriented C and normal, run-of-the-mill C?
Erik
adams.e@oxy.edu

jpd00964@uxa.cso.uiuc.edu (07/24/89)

> what are the primary differences between
> object-oriented C and normal, run-of-the-mill C?

Object oriented C can be one of two things.
1> objective C, which is a preprocessor, therefore effectively run-of-the-mill
C with some standard routines to do object oriented programming.
2>  C++ which is an extension to c and therefore not normal C.

Object oriented programming is a method of storing routines in "objects" with 
their variables.  This allows easy portability.  I can in a given object,
define my variables to be any name since only these routines can affect the
variables.  The methods (functions by a different name) can be accessed by 
any other object.  So if you have a pointer to your object, and a routine
offset table, then can always indirectly get any variable.

The advantages:
All objects can be made interchangable.  For example.  If I have a cup object, 
that keeps track of the weight of all objects in it.  As I add a new object, 
it just needs a method called getWeight.  The cup will call getWeight and
my new object will return the correct weight.  The cup does not have to
concern itself with how a pen and another cup differ, the same called method
will concern itself. 

I have a better idea, read Object oriented programming by Cox.  It's a very
good book

Michael Rutman
Softmed

emb90619@uxa.cso.uiuc.edu (Eric M Berdahl) (07/26/89)

In article <227700016@uxa.cso.uiuc.edu> jpd00964@uxa.cso.uiuc.edu writes:
>Object oriented C can be one of two things.
>1> objective C, which is a preprocessor, therefore effectively run-of-the-mill
>C with some standard routines to do object oriented programming.
>2>  C++ which is an extension to c and therefore not normal C.

Not exactly, C++ is also a preprocesor, just different enough to be considered
a different language.  In fact, if you look at most any C++ implementation,
you will find a cfront "preprocessor" and a C compiler are the basic pieces
of the system.

>Object oriented programming is a method of storing routines in "objects" with 
>[deleted short explanation of s]

Also, OOPs incorporates concepts of captulization, and other things which,
ideally, would be adhered to.  The main idea is to think in terms of "objects",
things that are autonomous, rather than thinking in terms of simple data
structures which have no existance of their own.

eric

***********************************************************************
* Eric M. Berdahl               * "Life has little to do with         *
* Amoco Technology Company      *  infinity and jelly doughnuts"      *
* Amoco Research Center         *                                     *
* PO Box 3011   MC F-2          * e-mail: berdahl@igor.nap.amoco.com  *
* Naperville, Illinois  60566   * Phone: (312) 420-3820               *
***********************************************************************

siegel@endor.harvard.edu (Rich Siegel) (07/26/89)

In article <1562@garcon.cso.uiuc.edu> emb90619@uxa.cso.uiuc.edu (Eric M Berdahl) writes:
>In article <227700016@uxa.cso.uiuc.edu> jpd00964@uxa.cso.uiuc.edu writes:

>Not exactly, C++ is also a preprocesor, just different enough to be considered
>a different language.  In fact, if you look at most any C++ implementation,
>you will find a cfront "preprocessor" and a C compiler are the basic pieces
>of the system.

	Not exactly. There are pure C++ compilers in existence, but most
implementors find it simpler to license cfront from AT&T and have it generate
code for their own C compilers.

	IMHO this is a real deficiency, because it's a realy slowdown to
the compiler - can you imagine how slow LightspeedC would be if there
were a C++ preprocessor tacked onto it? Also, using a preprocessor
makes it very difficult to offer source-level debugging for the 
preprocessed code.

		--Rich
~~~~~~~~~~~~~~~
 Rich Siegel
 Staff Software Developer
 Symantec Corporation, Language Products Group
 Internet: siegel@endor.harvard.edu
 UUCP: ..harvard!endor!siegel

"When it comes to my health, I think of my body as a temple - or at least
a moderately well-managed Presbyterian youth center." - Emo Phillips

~~~~~~~~~~~~~~~

ts@cup.portal.com (Tim W Smith) (07/26/89)

< Object oriented C can be one of two things.
< 1> objective C, which is a preprocessor, therefore effectively run-of-the-mill
< C with some standard routines to do object oriented programming.
< 2>  C++ which is an extension to c and therefore not normal C.

C++ is often ( most of the time? ) implemented as a preprocessor, so
therefore, according to the above, is effectively run-of-the-mill
C.

					Tim Smith

nagel@paris.ics.uci.edu (Mark Nagel) (07/26/89)

ts@cup.portal.com (Tim W Smith) writes:

>C++ is often ( most of the time? ) implemented as a preprocessor, so
>therefore, according to the above, is effectively run-of-the-mill
>C.

Just because a compiler's target language is C doesn't mean that the
language translated by the compiler is C.  That's just as absurd as
saying that C (or any other HLL) is simply a preprocessor for
assembly language!
-- 
Mark Nagel
UC Irvine, Department of Information and Computer Science
ARPA: nagel@ics.uci.edu         UUCP: ucbvax!ucivax!nagel

marti@ethz.UUCP (Robert Marti) (07/27/89)

In article <2286@husc6.harvard.edu>, siegel@endor.harvard.edu (Rich Siegel)
writes:
> Can you imagine how slow LightspeedC would be if there were a C++
> preprocessor [ a la cfront ] tacked onto it?
Can you say SnailspeedC++ (TM)?  :-)

> Also, using a preprocessor makes it very difficult to offer source-
> level debugging for the preprocessed code.
Yes.
-- 
Robert Marti                      Phone:      +41 1 256 52 36
Institut fur Informationssysteme
ETH-Zentrum                       CSNET/ARPA: marti%inf.ethz.ch@relay.cs.net
CH-8092 Zurich, Switzerland       UUCP:       ...uunet!mcvax!ethz!marti

amanda@intercon.UUCP (Amanda Walker) (07/28/89)

In article <20114@paris.ics.uci.edu>, nagel@paris.ics.uci.edu
(Mark Nagel) writes:
   ... That's just as absurd as
   saying that C (or any other HLL) is simply a preprocessor for
   assembly language!

Well, I'd say that C is, actually ...  More accurately, it's the most
powerful and portable assembler I've ever used, but I wouldn't call it
a HLL.  C++ is getting there, but it's facilities for abstraction are
still pretty rudimentary.

Give me a good modern Lisp any day!

--
Amanda Walker <amanda@intercon.uu.net>
InterCon Systems Corporation
--
"A keyboard ... how quaint!"  -- Scotty, Star Trek IV: The Voyage Home

jpd00964@uxa.cso.uiuc.edu (07/30/89)

>  the value/disadvantages of a preprossessor

ok, I think this has gone on long enough.

I believe it started with my comment that Objective C is a preprocessor
that adds onto C and C++ is not.

People have replied that C++ also has a preprocessor in some versions.

Let us sit back and think.  C++ with a preprocessor is very different than
what I meant.  Objective C is converted to standard C (or rather ansi), not
a tokenized version, not a parsed C syntac type thingy, I mean C code.  It
converts the smalltalk syntax to straight C.  

C++ is not defined to do that.  There may be versions that do that, but
C++ does not have to.  Objective C has to be converted to C.  That means
that Objective C is run of the mill C with a couple of neato-nifty highly
proprietary routines from StepStone and a couple of shortcuts to help
you think object-oriented.  C++ is a new language.  

Before anyone says "yeah, but C++ is also preprocessed into C",
Let me ask this, "Does everyone remember using Pascal that is "pre-processed"
into C.  It was put through a lexical analyzer and ended up in c tokens, but
not c code.  That means that it is as correct to say C++ is run-of-the-mill
C as it is to say Pascal is.  I better not hear anyone say C and Pascal are
anything close to the same!!!! (:->)

Now!!!! Bang, pop peoples bubbles time.
C++ is not the same as objective-C.  I know because I am training someone
who knows C++ very well.  We are on a NeXT with Objective-C.  C++ is
missing some of the elements that make Objective-C as powerful as it is.
I know some of the people in this string will find it hard to believe, but
Objective-C is much, much more powerful and useful than C++.  Do not quote
Stroushoup (or however you spell it) until you have read Cox.  When
you realize how to use self and super, you will realize that C++ is for 
peons.

A short aside to Symantics:

My condolences for choosing C++ over Objective-C.  I have always loved your
LSC, but I cannot see downgrading my object oriented language.  However,
if you were to include a short easy preproccesor for the Objective-C, then
everyone could use regular C, C++, or Objective-C all in one.  Of course
that's assuming the run-time code is possible to get from Stepstone for
a reasonable rate

Michael Rutman
Softmed