Nor will you ever have. Which is better, a horse or a cow?
Nope, they are just different. C++ is based on C and has some
interesting additional features useful to OOP like templates.
The only points I'd feel to give to C are
* better legibility: C++ allows too much overloading, which is good
only if well-documented otherwise is hellish.
* more low-level: if you are already an organised and neat programmer
C gives you a more in-depth vision of the whole code and organization
(headers instead of classes etc.)
PS: sorry If I made grammatical mistakes.
As always, there are no hard or fast truths, here. What's "better"
for one if worse for the other.
* C doesn't need supporting code (C++ needs such for exceptions,
RTTI, construction of static objects etc.)
* C is "more like assembler", giving some people a greater feeling
of control over what's really going on. Mind you, skilled C++
coders have the same amount of control, but see next point.
* C is less complex, and comparatively easy to understand "in full",
i.e. knowing the whole language including the standard library
and no longer stumbling over things unknown.
* C has the easier grammar (from a computer's point of view), making
it easier to come up with tools for it (compilers, pretty printers
etc.).
* C is supported on just about every platform. On some of the more
esoteric ones, getting a competent C++ compiler still is an isssue.
* In C++, there are many people around who think they're competent,
but aren't really. That might even be the same with C, but with
C++ there are many more ways to screw up real bad.
On the downside, C lacks *much* of the expressiveness of C++, which
gets clearer the larger the project. You didn't ask for the reverse
argument, which is why I won't get into the advantages of C++ in
detail, but there's a certain project size beyond which I would not
consider C an option anymore.
Regards,
--
Martin Baute
so...@rootdirectory.de
> I was wondering, what are some reasons why C is superior to C++? I
> definitely like programming in it better, I just don't have any hard
> evidence. What are your thoughts?
It's narrow and simple.
I like it more too.
C++ wouldn't exist if C was, in every context, superior to C++. The
reverse is also true; C would be dead by now, replaced by C++, if C++
were in every way superior to C. Each language has its strengths and
weaknesses, and for each of those languages there are some contexts
where it's advantages make it the superior one; and there are additional
context where neither language is appropriate
The key advantage of C is it's simplicity compared to C++. Almost every
feature of C is also a feature of C++, and C++ adds LOTS of additional
features. The entire C library is incorporated by reference into the C++
library, with relatively minor modifications, and then C++ has lots of
additional library components. While most C++ programmers use only a
limited subset of C++ features that may, in itself, be no more
complicated than C, anyone who intends to do maintenance work on C++
code written by someone else will have to be at least familiar with
every feature that the other person might choose to use. Therefore, a
good C++ programmer has to understand a much more complicated language
than a good C programmer. This makes it harder to learn, harder to
teach, and harder to master
That simplicity also makes it easier to port C to a new platform
quickly. You might think that it's simplicity would also give it better
performance, and at the most basic level that's true. However, modern
sophisticated C++ compilers can generate code that matches (and even, in
certain specialized contexts, exceeds) the performance of corresponding
C code
There's a trade-off between the two languages in terms of how easy it is
to make, find, and correct errors. The greater complexity of C++ makes
it easier to make errors, harder to find them, and harder to figure out
the best way to correct them. However, the designers of C++ were not
idiots; most of the additional features of C++ were designed with the
explicit intent of making it easier to avoid making particular types of
errors, when those features are used correctly. For instance,
constructors and destructors make it easier to ensure that "Bookend"
code is executed whenever necessary, and in a consistent fashion. To a
considerable extent, those designers achieved that goal. However, the
advantages can disappear if those features are used incorrectly, and
most C++ programmers, like most programmers for any language, are not
language gurus who know all of the rules needed to use those features
correctly.
In my personal experience, debugging C++ code can be very difficult
because it can be hard to track down exactly where some particular
feature of a program is (or should be) implemented. The key features
that make this difficult are function overloading, and in particular,
operator overloading, but inheritance makes its own unique contribution
to the confusion. However, I've nearly three decades of experience with
C, and no more than a few months of actual C++ experience, so this may
merely reflect my lack of experience.
The horse, obviously. I've never heard of anyone betting on a cow race.
--
Kenneth Brody
Bjarne Stroussup (sp?) wrote an article on that one april first.
basically it boiled down to C is smaller and therofore easier to
master.
--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---
> I was wondering, what are some reasons why C is superior to C++? I
> definitely like programming in it better, I just don't have any hard
> evidence. What are your thoughts?
I work in the production of software components: libraries that are
licensed to lots of companies for use within their applications.
Providing the interfaces to these libraries as C, rather than C++
interfaces, makes it a great deal easier to cope with slightly different
compiler versions, and to make changes to the interfaces in an
upwards-compatible manner. We thus use C interfaces wherever possible.
--
John Dallman, j...@cix.co.uk, HTML mail is treated as probable spam.