[comp.lang.c++] What is Objective C?

cjoslyn@bingvaxu.cc.binghamton.edu (Cliff Joslyn) (08/20/90)

Well, the subject line says it all.  What is Objective C? How does it
compare with C++? What is the title of a good book?

Thanks.

-- 
O------------------------------------------------------------------------->
| Cliff Joslyn, Cybernetician at Large, cjoslyn@bingvaxu.cc.binghamton.edu
| Systems Science, SUNY Binghamton, Box 1070, Binghamton NY 13901, USA
V All the world is biscuit shaped. . .

jimad@microsoft.UUCP (Jim ADCOCK) (08/21/90)

Please post follow-ups to comp.object.  Use comp.lang.c++ for discussing
C++.  Use neutral forums for language wars.

patrickd@chinet.chi.il.us (Patrick Deupree) (08/23/90)

In article <3864@bingvaxu.cc.binghamton.edu> cjoslyn@bingvaxu.cc.binghamton.edu (Cliff Joslyn) writes:
>
>Well, the subject line says it all.  What is Objective C? How does it
>compare with C++? What is the title of a good book?
>

I believe that Objective C is an actual Object Oriented C compiler whereas
C++ is a pre-processor.  This basically means that C++ code is translated
into C code which is then compiled into a final form.  Some would argue that
this makes it somewhat a kludge and they don't want to use it.  Objective
C is sometimes thought of as a more "pure" object oriented solution to
C.  These issues arose in a heated discussion with one of our R&D folk when
I said C++ wasn't bad and he talked of the virtues of Objective C.

(It's been a while since I've gone over all this so I may be wrong.)
-- 
"Organized fandom is composed of a bunch of nitpickers with a thing for
 trivial pursuit."  -Harlan Ellison

Patrick Deupree ->	patrickd@chinet.chi.il.us

strobl@gmdzi.UUCP (Wolfgang Strobl) (08/24/90)

patrickd@chinet.chi.il.us (Patrick Deupree) writes:

>I believe that Objective C is an actual Object Oriented C compiler whereas
>C++ is a pre-processor.  This basically means that C++ code is translated
>into C code which is then compiled into a final form.  Some would argue that
>this makes it somewhat a kludge and they don't want to use it.  Objective
>C is sometimes thought of as a more "pure" object oriented solution to
>C.  These issues arose in a heated discussion with one of our R&D folk when
>I said C++ wasn't bad and he talked of the virtues of Objective C.

C++ is a language, not a pre-processor. The C++ compiler I use (Zortech 
C++ version 2.1) is a two pass compiler which compiles to the usual
object file format, and it is as fast as the usual C compilers.
As far as I know, Turbo C++ isn't implemented as a pre-processor, either.

I like C++ better than any other OO language dialect, because it
implements OO concepts quite similar to SIMULA67, the yet unsurpassed
grandfather of all object oriented languages. 

And, yes, it allows developement for MS Windows. (-:

Wolfgang Strobl
#include <std.disclaimer.hpp>

sarima@tdatirv.UUCP (Stanley Friesen) (08/24/90)

In article <1990Aug23.151011.12954@chinet.chi.il.us> patrickd@chinet.chi.il.us (Patrick Deupree) writes:
>In article <3864@bingvaxu.cc.binghamton.edu> cjoslyn@bingvaxu.cc.binghamton.edu (Cliff Joslyn) writes:
>>
>>Well, the subject line says it all.  What is Objective C? How does it
>>compare with C++? What is the title of a good book?
>
>I believe that Objective C is an actual Object Oriented C compiler whereas
>C++ is a pre-processor.  This basically means that C++ code is translated
>into C code which is then compiled into a final form.  Some would argue that
>this makes it somewhat a kludge and they don't want to use it.

This is a compiler implementation issue.  Only some C++ compilers use C as
the 'assembly' language, others produce direct machine code.  [This is just
like some C compilers producing assembly output and running it through asm,
which some early UNIX C compilers did].

It is certainly not a requirement of C++ that it be compiled into C.

> Objective
>C is sometimes thought of as a more "pure" object oriented solution to
>C.  These issues arose in a heated discussion with one of our R&D folk when
>I said C++ wasn't bad and he talked of the virtues of Objective C.
 
The main difference is that Objective-C is a Smalltalk based extension to C,
while C++ is a Simula based extension to C.

The choice depends on whether you prefer the purely dynamic binding, tree
search style of method resolution; or a type-safe, fixed search style of
method resolution with optional static binding.

hansen@pegasus.ATT.COM (Tony L. Hansen) (08/25/90)

< I believe that Objective C is an actual Object Oriented C compiler whereas
< C++ is a pre-processor.  This basically means that C++ code is translated
< into C code which is then compiled into a final form.  Some would argue
< that this makes it somewhat a kludge and they don't want to use it.
< Objective C is sometimes thought of as a more "pure" object oriented
< solution to C.

For Pete's sake! Get your facts straight.

Objective C is an object oriented	C++ is an object oriented language
language and essentially a		and essentially a superset of C.
superset of C.

Compilers for Objective C are		Compilers for C++ are available
provided by Stepstone, Inc. They	from several sources, such as
produce object code directly and	AT&T's cfront translator, Oregon
may possibly even produce C code,	Software, Zortech and Borland.
for all I know.				Those compilers based on cfront
					produce C as an intermediate
					assembly language, which is then
					further compiled into object code.
					Those compilers provided by the
					other companies produce object
					code directly. All of these
					compilers, even cfront, are full
					compilers; they just use different
					forms of assembly language as
					their outputs.

Some people think that the syntax	The syntax of C++'s objects look
of Objective C's objects look more	more like C's structures. Message
similar to Smalltalk objects.		passing may or may not be
Message passing is almost always	polymorphic.
polymorphic.

Objective C has a number of class	C++ has a number of class
libraries available from		libraries available from a variety
Stepstone.				of sources.

If you define an "object oriented solution to C" as "most like Smalltalk",
then Objective C undoubtedly wins the appellation. Most people I know do NOT
use such a definition.

The C, C++ and Objective C preprocessor is that part of the compilation
system which deals with #include statements and their kin.

< These issues arose in a heated discussion with one of our R&D folk when I
< said C++ wasn't bad and he talked of the virtues of Objective C. (It's
< been a while since I've gone over all this so I may be wrong.)

I suggest that you and your R&D person learn a bit more about both
languages. I've leave the rest of the conclusion drawing to others. I'll
admit to being somewhat biased. :-)

					Tony Hansen
				att!pegasus!hansen, attmail!tony
				    hansen@pegasus.att.com

P.S. Where does the expression "For Pete's sake" come from?

ark@alice.UUCP (Andrew Koenig) (08/25/90)

I would like to add one thing to Tony Hansen's remarks.

Cfront is a compiler that works roughly like this:

	1. Read and parse a C++ program into an internal representation.

	2. Walk through the internal representation translating the
	   parts of C++ that aren't in C into the corresponding C code.

	3. Print out C source code corresponding to the internal representation.

Now, (3) is a very small part of cfront -- somewhere around 5 percent
of the total code.  The reason it's there, of course, is that it wouldn't
be very useful if all you got was internal representation!

In other words, as you get it from AT&T, cfront is a C++ compiler front
end coupled with a straightforward C-generating back end.

Now, why do we do this?  There are two reasons:

	1. Our primary customers are companies that bundle cfront together
	   with whatever other compilation technology they may be selling.
	   If we were to generate machine code for their particular
	   machines, they would probably want eventually to rip out our
	   code generator and substitute theirs anyway.
	
	2. We want to make it as easy as we can to get C++ running on a
	   new machine.

Reason (1) implies that it is possible for our customers to remove
the C code generator from cfront and substitute their own machine-code
generator.  And indeed one of our customers has done exactly that:
if you buy their C++ system for their machines, you get cfront + their
code generator in a package that only generates machine language.
I don't think it's even possible to get C out.

Other companies have done similar things.  For example, there's one other
that instead of generating C in ASCII form, generates it as a stream of
tokens that is then fed directly into the syntax analysis phase of their
C compiler.  Others do it the straightforward way -- just generate
C and be done with it.
-- 
				--Andrew Koenig
				  ark@europa.att.com

kitchel@iuvax.cs.indiana.edu (Sid Kitchel) (08/25/90)

strobl@gmdzi.UUCP (Wolfgang Strobl) writes:

>I like C++ better than any other OO language dialect, because it
>implements OO concepts quite similar to SIMULA67, the yet unsurpassed
>grandfather of all object oriented languages. 

	Yes it is clear that many share your like of C++ as both a
close relative of Simula and C, our favorite easy-to-get-yourself-in-
trouble language. Others, like myself, prefer languages with a greater
degree of object orientation within their design. I personally think
that having objects and messaging as an integral part of the language
is cleaner and more useful than being tacked on the side. But, of 
course, that will not deter C++ becoming even more popular. I guess
I'm just a spoiled sport purist.
							--Sid

-- 
Sid Kitchel...............WARNING: allergic to smileys and hearts....
Computer Science Dept.                         kitchel@cs.indiana.edu
Indiana University                              kitchel@iubacs.BITNET
Bloomington, Indiana  47405-4101........................(812)855-9226

nick@abblund.se (08/27/90)

In article <1990Aug23.151011.12954@chinet.chi.il.us> patrickd@chinet.chi.il.us (Patrick Deupree) writes:
>
>I believe that Objective C is an actual Object Oriented C compiler whereas
>C++ is a pre-processor.  This basically means that C++ code is translated
>into C code which is then compiled into a final form.  

Wrong!

There are several C++ implementations available. Some are pre-processors,
some are compilers.
To my knowledge Objective-C is so far only available as a pre-processor,
but there is nothing to stop anyone from making a compiler.

>Patrick Deupree ->	patrickd@chinet.chi.il.us

-- 
Nick Hoggard                                   Phone:    + 46 46 168524
Man-Machine Communication Lab                  Fax:      + 46 46 145620
ABB Corporate Research, Dept KLL               Internet: nick@abblund.se
Ideon Research Park, Ole Roemersvaeg 5, S-223 70 Lund, Sweden

cox@stpstn.UUCP (Brad Cox) (08/27/90)

In article <11233@alice.UUCP> ark@alice.UUCP (Andrew Koenig) writes:
}Cfront is a compiler that works roughly like this:
}
}	1. Read and parse a C++ program into an internal representation.
}
}	2. Walk through the internal representation translating the
}	   parts of C++ that aren't in C into the corresponding C code.
}
}	3. Print out C source code corresponding to the internal representation.
}
}Now, (3) is a very small part of cfront -- somewhere around 5 percent
}of the total code.  The reason it's there, of course, is that it wouldn't
}be very useful if all you got was internal representation!

This should be so obvious that I needn't point out that the Objective-C 
*compiler* does the same things, in precisely the same fashion, for exactly
the same reasons. 

The Objective-C *interpreter* does not, again for reasons that should 
be obvious.  The downside of the difference is why the interpreter is 
presently available only for an old version of the language, and not 
on the newest machines.
-- 

Brad Cox; cox@stepstone.com; CI$ 71230,647; 203 426 1875
The Stepstone Corporation; 75 Glen Road; Sandy Hook CT 06482

jimad@microsoft.UUCP (Jim ADCOCK) (08/28/90)

comp.lang.objective-c has just been voted into existence, so please 
follow-up to this question there.

lerman@stpstn.UUCP (Ken Lerman) (08/28/90)

In article <11233@alice.UUCP> ark@alice.UUCP (Andrew Koenig) writes:
->I would like to add one thing to Tony Hansen's remarks.
->
->Cfront is a compiler that works roughly like this:
->
->	1. Read and parse a C++ program into an internal representation.
->
->	2. Walk through the internal representation translating the
->	   parts of C++ that aren't in C into the corresponding C code.
->
->	3. Print out C source code corresponding to the internal representation.
->

Ditto for Objective-C.  Except that for some constructs, steps 2 and 3
are done in parallel.  (substituting Objective-C for C++, of course)

[...stuff deleted...]
>-- 
>				--Andrew Koenig
>				  ark@europa.att.com

Disclaimer: Although I ought to know, since I look at the compiler
source every day, these opinions (do they look like facts? ) are mine
and I represent myself.

Ken Lerman

mat@mole-end.UUCP (Mark A Terribile) (08/29/90)

In article <4998@pegasus.ATT.COM>, hansen@pegasus.ATT.COM (Tony L. Hansen) writes:

> 					Tony Hansen
> 				att!pegasus!hansen, attmail!tony
> 				    hansen@pegasus.att.com
> 
> P.S. Where does the expression "For Pete's sake" come from?

Well, since you asked it on this newsgroup ...

In *The Great Divorce* by C. S. Lewis, one character says ``I have only
been trying to please *you*, for peace sake.''  As in `for peace's sake,'
as in `for the sake of peace.'

I don't know if this is the real derivation, but seems plausible.

Now, would someone tell us the derivation of `For the love of Mike ...'?
-- 

 (This man's opinions are his own.)
 From mole-end				Mark Terribile

pcg@cs.aber.ac.uk (Piercarlo Grandi) (08/29/90)

On 25 Aug 90 15:01:58 GMT, ark@alice.UUCP (Andrew Koenig) said:

That cfront is a C++ compiler compiler that generates C code instead of
assembler, then adds:

ark> Other companies have done similar things.  For example, there's one other
ark> that instead of generating C in ASCII form, generates it as a stream of
ark> tokens that is then fed directly into the syntax analysis phase of their
ark> C compiler.

I remember Stroustrup writing that the 1.x cfront had not just a C
backend but that is could also use as backend the pcc backend, much in
the same way as f77 does it.

Is that still possible with cfront 2.x, without too much trouble? There
are all those BSD systems around that use pcc, and this would be a nice
way to make compilation times shorter on those systems.
--
Piercarlo "Peter" Grandi           | ARPA: pcg%uk.ac.aber.cs@nsfnet-relay.ac.uk
Dept of CS, UCW Aberystwyth        | UUCP: ...!mcsun!ukc!aber-cs!pcg
Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk

bs@alice.UUCP (Bjarne Stroustrup) (08/30/90)

Piercarlo Grandi says:

 > I remember Stroustrup writing that the 1.x cfront had not just a C
 > backend but that is could also use as backend the pcc backend, much in
 > the same way as f77 does it.

Almost correct. I had an assembler generating version planned and cfront
collects much information needed for that in its tables, but I never got
around to actually writing that version.
	
 > Is that still possible with cfront 2.x, without too much trouble? There
 > are all those BSD systems around that use pcc, and this would be a nice
 > way to make compilation times shorter on those systems.

It can be done - and the proof is that it actually has been done.