Re: [dev] [OT] What's wrong with C++?

From: David Tweed <>
Date: Fri, 10 Sep 2010 21:23:09 +0100

On Fri, Sep 10, 2010 at 7:19 PM, Paolo <> wrote:
> Why program in C++ when you can do it in C, making the program simpler and better?

One of my maxims is that "everyone mistakenly thinks that the kind of
programs that they write are the kind of programs everyone writes".
There are some domains in which C is simpler, there are some domains
in which C++ yields simpler programs, assuming you account carefully
for all the complexity caused by macros and conventions which have to
be ensured by the programmer. (Incidentally, I think the "I only use
10 per cent of the language, so it must be bloated" are people who
don't realise not everyone writes the kind of programs they do, and
would presumably also object to a natural language which is big enough
to be usable by both poets and lawyers. Now, complaints about the bad
interaction between C++ features are more justified...)

My opinion on C++ is, basically, every major feature in C++ is in
response to a real "difficulty" in programming that's worth attempting
to ameliorate, but the solutions chosen by C++ are often suboptimal,
and very often interact badly with other features. I'm also of the
opinion that many of the worst elements of C++ are due to the design
requirement to "in essence" have a block of code which is valid C have
the same semantics as in C (and to some extent the desire to keep
using object file/linker formats bassed in the 70s); that strongly
constrains some important basics to annoying things. My biggest
concern about the latest evolving standard C++0x is that it attempts
to cram even more functionality into a design space that's already
highly constrained by both C compatibility and existing C++
compatibility. Of course, Stroustrup argues that C++ wouldn't have
become popular had it not constantly been presented as incremental

A lot of my work is writing numerical code that is quite performance
critical. As such, I find it almost invaluable to be able to write a
template function so that one source base can work on int8_t's, ....,
floats, doubles, complex<float>, etc, with proper typechecking rather
than in C with kludges using macros that render debugging a nightmare.
That combined with C++'s namespaces (which whilst not a proper module
system, are a godsend if you need to QUICKLY create a program which
uses two existing libraries that happen to use the same name) is
enough to mean that, FOR MY KIND OF PROGRAMMING, I'd rather use MY
subset of C++ that doesn't have bad interactions than have to write in
C doing lots of C++ stuff by hand. But I expect some people working on
other kinds of problems have their own subset of C++ that they use,
and some people working on other kinds of programming are best served
by C.

So for me, C++ is basically a good idea with a botched implementation,
and I think it's a bit of a shame that D Java has semantics designed
for a managed interpreter, D still appears to be primarily supported
by a few developers, that Go does not have any interest in efficient
numerical computation, BitC appears to have only one developer, etc.
To be honest, if it wasn't so heavily based on an ecosystem, and
possibly legal issues, that are controlled by Microsoft I might have
tried moving to C#.

cheers, dave tweed__________________________
computer vision reasearcher:
"while having code so boring anyone can maintain it, use Python." --
attempted insult seen on slashdot
Received on Fri Sep 10 2010 - 22:23:09 CEST

This archive was generated by hypermail 2.2.0 : Fri Sep 10 2010 - 22:24:02 CEST