[comp.sys.next] Objective-C vs C++

garl@nlm-mcs.arpa (Gary Letourneau) (11/01/88)

  Now that Objective-C is being bundled with the NeXT machine, I would like
to pose the following question: how does Objective-C compare with C++.
I believe that this was discussed at great length in one of the newsgroups 
sometime in the last year or so, but because of this new development, it
should prove beneficial to once again present a comparison. To try to reduce
the ammount of traffic on this topic, if you mail to me at the email address
below I'll post a summary.

						Gary Letourneau
						letourneau@mcs.nlm.nih.gov

david@beowulf.JPL.NASA.GOV (David Smyth) (11/01/88)

In article <8335@nlm-mcs.arpa> garl@nlm-mcs.arpa (Gary Letourneau) writes:
>
>  Now that Objective-C is being bundled with the NeXT machine, I would like
>to pose the following question: how does Objective-C compare with C++.

This is going to cause some discussion, and I think that is what the
net is for.  Therefore, I'm posting to the net rather than e-mail as
was suggested.

At USENIX/C++, I said that C++ is too complex.  Much recent net
discussion has added support to this claim.  C is basically simple
(declarations and operator precedence are awful, of course).  C++ is
incredibly complex.  The number of caveats which productive C++
programmers must grasp is simply too large: must have virtual
destructors, can't have virtual constructors (makes sense, but it is
obscure); when one must use [] on delete, and when they are not needed;
only use multiple-inheritance when you have the source of all classes
back to their roots because a client can introduce bugs which a C++
compliler won't catch; etc. etc. etc.

I am not convinced that Objective-C is a good way to go: lack of strong
typing for example.  However, it is certainly a MUCH smaller addition
to C than C++.

Face it: the only reason we are talking about using C++ or Objective-C
is because of a desire to be "upwardly compatible" with existing C
code.  Note, however, that C++ IS NOT "upwardly compatible" with C,
rather C++ IS A DIFFERENT LANGUAGE!  Just try including <sunview.h>,
and you will see what I mean.  Or any large C language program!  It
won't compile with a C++ compiler.  The more recent enhancements to the
language continue to widen, rather than narrow, the difference in
semantics between C++ and C.

Since people are willing to use C++ anyways, perhaps what we should
REALLY do is create a new, GOOD object language, and call it, say, ++C,
and use it instead.  Besides, the name would then be semantically
correct! :-)

I think it was and is a good idea for any new language to generate C as
an assembly language, like cfront does.  True, a C compiler cannot make
some optimizations which a C++ compiler can make, because some
semanitcs are lost in the translation.  This is usually not significant
to early implementations based on a prototype language anyway.

ark@alice.UUCP (Andrew Koenig) (11/01/88)

In article <3438@jpl-devvax.JPL.NASA.GOV>, david@beowulf.JPL.NASA.GOV (David Smyth) writes:
> Face it: the only reason we are talking about using C++ or Objective-C
> is because of a desire to be "upwardly compatible" with existing C
> code.  Note, however, that C++ IS NOT "upwardly compatible" with C,
> rather C++ IS A DIFFERENT LANGUAGE!  Just try including <sunview.h>,
> and you will see what I mean.  Or any large C language program!

C++ is programmer compatible with C.  By this I mean the following:

	You can take a large project with a bunch of C programmers
	and have them writing working equivalent C++ programs in
	a day or less.

	You can convert your system from C to C++ a module at a time
	without having to throw the whole thing out and start over.

	You can write large systems that will compile in both C++
	and ANSI C without change and do the same thing.

	A good C++ programmer can convert about 1,000 lines of
	old C an hour to C++.  Converting ANSI C should be faster.

> Since people are willing to use C++ anyways, perhaps what we should
> REALLY do is create a new, GOOD object language, and call it, say, ++C,
> and use it instead.  Besides, the name would then be semantically
> correct! :-)

Cfront, the first implementation of C++, increments C and yields
C as its output.  Thus C++ is a more appropriate name than ++C.
-- 
				--Andrew Koenig
				  ark@europa.att.com

cjosta@taux01.UUCP (Jonathan Sweedler) (11/01/88)

In article <8375@alice.UUCP> ark@alice.UUCP (Andrew Koenig) writes:
>
>C++ is programmer compatible with C.  By this I mean the following:
>
>	You can take a large project with a bunch of C programmers
>	and have them writing working equivalent C++ programs in
>	a day or less.

Big deal.  I learned Pascal in a few hours after knowing C.  Does this
mean Pascal is "programmer compatible" with C?  Well then so is
Fortran, Cobal, etc...  That doesn't change the fact that converting
large, complex programs from one language to another is a large,
complex task.  Maybe converting from C to C++ is easier, but it
is still a tedious, error prone task.

>
>	A good C++ programmer can convert about 1,000 lines of
>	old C an hour to C++.  Converting ANSI C should be faster.

Yeah, right.  An then how about debugging?  The whole point about
*compatability* is that you don't have to do this conversion that
is NEVER as easy as it seems.  And what do you mean by "good" C++
programmer?  Certainly not the same programmer that learned C++
"in a day or less."  Everything looks good in the best-case light.
I don't think things are as easy in real life.

>
>Cfront, the first implementation of C++, increments C and yields
>C as its output.  Thus C++ is a more appropriate name than ++C.
>-- 

A rose by any other name... :-}

-- 
Jonathan Sweedler  ===  National Semiconductor Israel
UUCP:    ...!{amdahl,hplabs,decwrl}!nsc!taux01!cjosta
Domain:  cjosta@taux01.nsc.com

cme@cloud9.UUCP (Carl Ellison) (11/01/88)

In article <3438@jpl-devvax.JPL.NASA.GOV>, david@beowulf.JPL.NASA.GOV (David Smyth) writes:
> 
> True, a C compiler cannot make
> some optimizations which a C++ compiler can make, because some
> semanitcs are lost in the translation.  This is usually not significant
> to early implementations based on a prototype language anyway.

(flame on)

PLEASE -- I've heard this argument, in various flavors, for years.

Prototype languages don't exist.  They hang on -- because their code
hangs on.

Burt Sutherland, ex- of Lincoln Labs and Xerox PARC, once said:
"Programs are like waffles -- you should always throw the first
one out."

Unfortunately, I've never seen anyone follow that maxim.

(flame off)

--Carl Ellison          ...!harvard!anvil!es!cme    (normal mail address)
                        ...!ulowell!cloud9!cme      (usenet news reading)
(standard disclaimer)

mikhe@tragicomix.liu.se (Mike Henry) (11/02/88)

In article <3438@jpl-devvax.JPL.NASA.GOV> david@beowulf.JPL.NASA.GOV (David Smyth) writes:
>...
>REALLY do is create a new, GOOD object language, and call it, say, ++C,
>and use it instead.  Besides, the name would then be semantically
>correct! :-)

    Does this imply that we should enhance C-language BEFORE using it??
    Wow, thats what I call fast learning!! (or does THAT imply something
    else... B^)

		-Mike
-- 
INET : mikhe@majestix.liu.se                                          ///
UUCP : {seismo,mcvax,munnari}!enea!liuida!majestix!mikhe             ///
ARPA : mikhe%majestix.{ida.liu.se,UUCP}@seismo.CSS.GOV           \\\/// What
SNAIL: Mike Henry, Alsattersg. 3C:20, S-582 51 Linkoping SWEDEN   \XX/ Else??

nobody@tekecs.TEK.COM (-for inetd server command) (11/03/88)

>In article <3438@jpl-devvax.JPL.NASA.GOV> david@beowulf.JPL.NASA.GOV (David Smyth) writes:

>>I am not convinced that Objective-C is a good way to go: lack of strong
>>typing for example.  However, it is certainly a MUCH smaller addition
>>to C than C++.

I received some recent information on Objective-C.
Objective-C now appears to allow strong typing.

Paul Scherf, Tektronix, Box 1000, MS 61-028, Wilsonville, OR, USA
paulsc@orca.GWD.Tek.COM			tektronix!orca!paulsc

fischer@iesd.uucp (Lars P. Fischer) (11/10/88)

In article <3438@jpl-devvax.JPL.NASA.GOV> david@beowulf.JPL.NASA.GOV (David Smyth) writes:
>I think it was and is a good idea for any new language to generate C as
>an assembly language, like cfront does.

Making a compiler generate some high-level language is easier than
making it generate machine code. If you're going to implement a
compiler for some new or experimental language, this is an effective
way to go. But please note that this has nothing to do with the
language, it's an implementation technique.

The AdaVantage Ada compiler for the Mac generates C. The GNU C++
compiler generates machine code. This is all up to the compiler
writer, not the language designer. 
-- 
Lars Fischer,  fischer@iesd.dk, {...}!mcvax!diku!iesd!fischer
We must remove the TV-induced stupor that lies like a fog
across the land.		- T. H. Nelson