From: imp@boulder.parcplace.com (Warner Losh) Subject: Re: C++ is yucky Date: Fri, 9 Jul 1993 16:32:51 GMT
And now, for the other side to respond in the C++ discussion. Hit 'n'
now if you don't want to read it.
In article <BWH.93Jul9024054@beach.cis.ufl.edu> bwh@beach.cis.ufl.edu
(Brian W. Hook) writes:
>Hmmmm, Linux doesn't compile under cc? And C++ is not portable....which
>version of C++ are we talking? 2.0? 2.1? 3.0? ANSI draft? g++? cfront?
It doean't matter. C++ is every bit as portable as ANSI C, if you
follow the same sorts of rules. We have a 250,000 line library and
40,000 line programs that compile and work in all these environments
(not to mention in about a dozen different platforms).
>> PERFORMANCE:
>> As noted earlier, much of the time gcc produces the same code for ANSI
>> C as it does for C++.
>
>I don't understand this....the performance difference between C and C++ is
>entirely up to the implementation.
And g++'s implementation is about the same as gcc's. Which is what we
were talking about.
>While this is true, using -Wall with gcc, or whatever switch for whichever
>compiler, will give you all the warnings you need. Remember, strict
>typechecking under C++ was implemented mostly to avoid name clashes with
>overloading functions.
Well, this is not true. -Wall won't detect cases where you have
declared the function as int foo(int,int,int) where you call it, but
later change it to be int foo(int,int,int,char *) where it is actually
defined. Type safe linkage will catch these problems.
>Objects, overloaded functions, and inheritance tend to obfuscate code in a
>big way.
While they can be used for these purposes, they don't have to be.
Again, I've seen good object oriented code in large libraries. It
makes sense and works well.
>C++ is NOT a very good language to write object oriented
>code, unless you try to use templates....code reuse really isn't an option
>with the current implementations of C++ unless templates are used, and they
>are kind of flaky. And g++ is not compatible with cfront from what I hear.
Sigh. It is possible, and I have done it, to write good object
oriented code that gives you a high degree of reuse in C++. There are
certain things that C++ isn't good for without tempaltes like you say,
but the set is fairly small.
g++ accepts basically the same language that cfront accepts. It is
not binary compatible with cfront, but there is no standard for
binaries in the C++ world. The differences are in the nit range and
are usually compiler bugs in g++ or cfront.
>So what is C++ code is easier for C++ programmers to read? What about
>beginning C++ programmers? Who can tell the difference when foo->bar() is
>called and bar is overloaded six classes deep, but not defined for the
>current class, or even worse, was forgotten to be made "virtual" so that
>the correct method would be called by some high level routine.
So C code is hard for FORTRAN prgrammers to read. This is irrelevant.
If you make something virutal in the base class, but forget to make it
virtual in higher classes, it is still virtual. I'm not sure what you
are complaining about. Walking up the class tree is a fairly easy
excercise for most C++ programmers. Many times it doesn't matter at
all what is being called, since you want object foo to do bar,
whatever that is. If you don't know what is being called, then you
can always use a debugger to step into the routine in question.
Warner
-- Warner Losh imp@boulder.parcplace.COM ParcPlace Boulder I've almost finished my brute force solution to subtlety.