C++ sucks

Martin Naef EMAIL HIDDEN
Thu Nov 22 20:00:36 CET 2007


Hi Peter

Peter Korsten wrote:
>> Ahh, here we have it - three days. After you've spent several years 
>> coding with something else. What the heck do you expect? Becoming an 
>> expert in a different language after just three days?
> 
> No, that would take a couple of weeks. But as I mentioned, I've been 
> looking at C++, with several long interludes, for the best part of ten 
> years now. Probably more than that, but in real development time, a bit 
> less than a year.

Ok, you don't like it - fair enough. I've used for the last 15 years 
(looking back - that's a bloody long time!!!).

> Garbage collection and return-by-reference makes your life as a 
> programmer just a lot easier. As does automatic bounds checking.

I'm not denying that. But when I try to do low-latency machine vision 
processing with a camera running at 200Hz, the last thing I need is 
garbage collection kicking in at the wrong moment, and bounds checking 
is going to kill the performance. Of course, your environment is 
different - if your application crashes the server, all the speed in the 
world doesn't matter anymore, hence a tool with lots of safety devices 
is what you need.

And if you believe that garbage collection ensures that you don't leak 
memory, think again.

> This is a simplified version of what happened to me when I tried to use 
> an abstract base class as the type for a template class (vector, to be 
> precise).

Ok, fair enough - you found something that doesn't work. I'm sure I 
could easily construct something that won't work in Java. What's the point?

>> Of course, Java has been designed years after C++ and hence profits from 
>> a bit of hindsight - it would be rather sad if it didn't do a few things 
>> more elegantly.
> 
> What worries me is that both Java and C++ come from C, but that Java 
> made the right choices - mostly, at least - from the start. Stroustrup
> could have made the same choices, but instead he decided to retain 
> backwards compatibility, and came up with this horrible syntax. And this 

As above: When they designed Java, they already had all the feedback 
from C++ programmers. The "horrible Syntax" is a matter of taste and 
personal preference.

> was not necessary, because the only things that differ between the 
> syntax of C and Java is that everything has to be a class, the use of 
> the 'new' keyword, and the absence of pointers.

The latter is a *very* fundamental difference, as you just figured out 
yourself.

>> No, you've replaced the family car with a Ferrari. It's not easy to 
>> handle, and certainly temperamental, but it doesn't have the extra 
>> baggage of other systems that holds you back when you have to get down 
>> to the nitty gritty stuff.
> 
> If we keep up the comparison to vehicles, I'd rather compare C++ to a 
> Centurion tank. A Ferrari is pleasing to the eye; C++ most certainly 
> isn't. You can also make an awful mess with a tank, which seems rather 
> appropriate for C++ (segmentation fault, core dumped).

There's a reason why I chose the Ferrari: It's fast, if you know what 
you're doing. For everyday driving, speed doesn't matter. But for what I 
do, it's crucial, and C++ gives me the right balance between a "proper" 
language while not preventing me from digging really deep.

That means C++ is a great language. For me.

Bye
Martin

-- 
http://www.navisto.ch
http://www.myspace.com/navisto



More information about the music-bar mailing list