2 ms·
I've never really got the "C++ dialects" argument so popular with C enthusiasts. Sure, C++ is several order of magnitudes more complex than C, and this complexi
by unscaled 11y ago
I've never really got the "C++ dialects" argument so popular with C enthusiasts. Sure, C++ is several order of magnitudes more complex than C, and this complexity breeds different dialects. But for an experienced C++ programmer, that's a stylistic problem (you generally end up disliking the dialect of about half of the libraries you use), not an intelligibility problem.
I've read many libraries, both C and C++, and I've never found C++ libraries particularly hard-to-read. There are a few libraries rife with deep template magic (Boost.MPL et al.) but they are hardly the rule.
The real problem with C++, is that truly competent developers are hard to find. I've worked with and interviewed countless C++ developers. Very few used anything from C++11 (except for auto perhaps), and most are essentially program C++ as C with Java-style classes bolted on top. Templates are few and far between, and manual memory management abounds.
So these incompetent C++ developers you hear about in Linus' frequent rants? They're mainly C developers who learned some C++.
Good C++ developers write cleaner code that's easier to read compared to C, but it takes more time to train one than it takes to train a C developers. But if you only care about fast developer training, Java, or even better, Go are much better choices than C.
- pekk 11y agoIf one particular language suffers so much from all its programmers being incompetent, it should raise the question of what about the language makes it so hard. You can't reasonably dispute that C++ is a gigantic language full of optional features. To be competent with C++, you really have to learn which features to use or not. It's too bad that not everybody agrees on which features to use! Blaming outgroup C developers for everything is a cop-out.
- unscaled 11y agoOh, if it was only so easy! There are many other languages which abound with incompetent programmers. Even an atrociously simple languages had many incompetent programmers over the years. On the other hand, there don't seem to be a lot of incompetent Haskell programmers. It's usually practical reasons which determine the influx of newbies with no previous experience and little incentive to learn to a language. Popularity-wise, C++ was the Java of the 90s, and many programmers came during that time and don't want to learn anything new. Many other programmers are essentially not willing to learn C++ features beyond the features they're already comfortable with. "Which features not to use" is another myth propagated by professional C++-bashers. There are very few features in C++ that you shouldn't use, and most of them are officially deprecated parts of the standard library. The real problem is developers who refuse to learn templates, because "void pointers are simpler", or reject std::array, because it's fancy C+11 stuff and writing "char myArray[100]" is much shorter than "std:array<char, 100> myArray;". They then go on to forget std::array ever exist, and complain that vector is too inefficient, so they're going to use C arrays all the way. If you're willing to use all these newfangled features like closures, initializer lists, 1-part for or constexprs, its' very hard to shoot yourself in the foot. It's very easy to shoot yourself in the foot by using raw C arrays or manual malloc/free though.
- lenkite 11y agoAs a Java developer, I have found the source code of well-designed C++ libraries (like libtorrent) actually a pleasure to read. While C libraries need lots of 'macro and typedef' hunting. Doable but a chore. Unfortunately, the Boost libraries are really arcane - template magic that gives me a headache. So, I guess I fall into 'incompetent C++ developer', but that is not a surprise as it hasn't been my working language for some years now.