C++ sucks

Peter Korsten EMAIL HIDDEN
Thu Nov 22 00:39:31 CET 2007


There. I said it. C++ sucks. Big time.

The last couple of years I've been working with Java, and while it has 
its quirks, it's quite easy to work with: the syntax is clear, it has a 
good range of features, and it takes care of a lot of things for you, so 
you can concentrate on writing code.

Now, I had to write a BER (Basic Encoding Rules) decoder. It's often 
used in telecommunications, and you could compare it with XML because 
there's all these nested data structures. But in contrast to XML, it's 
binary.

And because you need to count bits and bytes, it's practically 
impossible to do in Java, also because Java can't work with unsigned 
integers or bytes, for reasons best known to the good people of Sun.

So I already had a working version, that I'd written in C. But because I 
needed to do additional things and work with lists and dynamic data 
structures, I decided that I needed C++, which, as we all know, is 
object-oriented.

After three days of swearing at it, I ditched what I'd written and 
rewrote the C program. My goodness, what was the man thinking when he 
designed (for want of a better word) C++?

The syntax is impossible to decipher without the Rosetta Stone, it 
doesn't have interfaces and therefore no clean separation between 
interface and implementation, you can't return objects except by 
reference which then keeps dangling (or as a pointer, which is even 
worse), and in general it's as Spartan as a barracks on the Peloponnese.

It's like you've been driving a nice family car for years, and then one 
morning you discover that someone has replaced it with a mule and cart. 
And a very stubborn mule at that.

Really, if you value your sanity, give C++ a wide berth and either use C 
or Java. C++ is like the unholy offspring of the two.

- Peter



More information about the music-bar mailing list