3 ms·
I don't really see a lot to like about C++. It's huge and fiendishly complex, keywords are overloaded to incomprehensibility, it doesn't make satisfactory guara
by brianpgordon 13y ago
I don't really see a lot to like about C++. It's huge and fiendishly complex, keywords are overloaded to incomprehensibility, it doesn't make satisfactory guarantees about static initialization, exception safety is too hard to reason about, it's full of features maintained for backwards compatibility even when they no longer make sense, and development tools are unacceptably inferior to Java and C#.
Pros are that it performs excellently and const correctness is pretty cool.
Let's get an old fashioned debate started!
- Kranar 13y ago>It's huge and fiendishly complex It's used to write software where that complexity is a minor cost in return for the performance it provides. >keywords are overloaded to incomprehensibility I don't know of a single keyword that is incomprehensible. Only a few keywords are overloaded but they are overloaded in contexts that make it very very clear what they're being used for. >doesn't make satisfactory guarantees about static initialization It makes very strong guarantees about static initialization. Static variables declared within a function are initialized when control flow passes through it for the first time, and such initialization is guaranteed to be thread safe. Global variables have three phases to their initialization, zero initialization, static initialization, and then dynamic initialization. Global variables are also initialized in the order that they are defined within a translation unit. > exception safety is too hard to reason about Exception safety is easier to reason about in C++ than any other language thanks to RAII. >it's full of features maintained for backwards compatibility even when they no longer make sense They make sense because no one wants to rewrite the billions of lines of code that their project might depend on that uses those features. Instead, it makes a lot more sense to just avoid using deprecated or backward compatible features rather than remove them from the language and break a crap load of invaluable software in the process. >development tools are unacceptably inferior to Java and C#. This is true.
- brianpgordon 13y ago> It's used to write software where that complexity is a minor cost in return for the performance it provides. Other languages (C, D, Ada, Go) provide similar native performance with far less complexity. > I don't know of a single keyword that is incomprehensible. Only a few keywords are overloaded but they are overloaded in contexts that make it very very clear what they're being used for. static, virtual, and class are all overloaded in weird ways. But punctuation is the worst: in particular commas, colons, ampersands, and asterisks are overused to absurdity. I'd almost prefer APL-like extra symbols to disambiguate some of the insane template one-liners that I've seen. > It makes very strong guarantees about static initialization. Are you saying that the static initialization order fiasco doesn't exist? C# and Java do not suffer from this problem. > Exception safety is easier to reason about in C++ than any other language thanks to RAII. I don't even know what to say to this one. Exceptions are notoriously wonky in C++. The language makes you resort to idioms like RAII and copy-swap to use them at all, instead of providing language-level support to solve those problems. > They make sense because no one wants to rewrite the billions of lines of code that their project might depend on that uses those features. Instead, it makes a lot more sense to just avoid using deprecated or backward compatible features rather than remove them from the language and break a crap load of invaluable software in the process. And as a consequence the language suffers. Historical reasons are not a valid defense of the present design of the language. I am reminded of this esr quote: "While we do not intend to insult the designers of C++, we will not make excuses for them either. They repeatedly made design choices that were well-intentioned, understandable in context, and wrong."