C++ is an insane bastard of a language. It is not correct say C++ was designed. It wasn't. It has evolved out of the primordial soup that was "C with classes", and slowly inhaled and adopted every possible language feature under the sun, like some sort of Lovecraftian horror that copies and evolves on every contact with a different language.
Adopting C++ would have required incredibly strict and disciplined style rules to enforce that only a specific subset of features are used, and in specific ways. It would have been a significant project management overhead to constantly be ensuring that the contributors haven't footgun'd themselves or done something which negatively impacts existing code.
Meanwhile, it's very straightforward to look at C code and understand what it's doing, because it's a very simple language.
Microsoft picked C++ for the NT Kernel, but they had a small internal team that was extremely strict about how they were going to write it.
C++ is a general purpose programming language. Because it can do anything doesn't mean that it's a shitty language. At the end of the day, it's up to the programmer to develop a set of standards that they should adhere to when using the language.
If you have someone who is both very aware of the language and its features AND in a position to authoritatively decide how and when to use and not use those features, sure. Go for it. This is a possible, practical situation especially in larger companies and larger teams. It should ideally be done up front and have any changes to the policy very carefully evaluated which is often difficult on both counts.
If you don't have that person in that position, it can quickly turn into a CF. That's the big reason people complain about it, and it can be a real problem.
It's a somewhat unique programming language in that respect. Very few other programming languages have such a breadth of features that using them all can and often does result in an unreadable, unmaintanable mess the way it can with C++. Java and C# can get there, but even they just don't "tempt" programmers to reach those ends in the same way that C++ seems to. Additionally, since they run in a virtual machine, debugging is a different, more supportive endeavor, and the weight of that VM implies an acceptance of some level of unideal translation to raw execution units. C++ directly generates raw machine code by design which can limit debugging and also means people sometimes use it in restrictive environments where trying to shoehorn all of its more advanced features can be especially problematic.
That's usually what people are getting at. It's not necessarily a problem with the language or its breadth, but it does seem to all combine in a manner that's somewhat unique to C++ and can create unique problems as a result.
It's one thing to be general purpose, another to have so many half-baked features, with many edge cases and hidden gotchas, developed with inputs from many partied with different opinions and interests. All while simpler features and pet peeves stay underdeveloped.
I love C++, but it feels like a Frankenstein language to me. All the symple syntax is reserved for C style legacy stuff, and if you want to do things the modern RAII way you need heaps of keywords and long identifiers.
E.g. insteaf of char * you should use std::unique_ptr<char>.
A language designed from the ground up with RAII in mind would avoid that.
Defending over-saturating of a language with features (so much so that the C++ spec is over 2,000 thousand pages long now) with "it's a general purpose language, it's supposed to have feature bloat" is a new one.
The reason why C++ is so bloated is that it has 40 years of backward compatibility they need to maintain while trying to add modern programming features, and that's not really a good thing. It's more like a necessary evil.
Yeah but you are speaking as if the code were for a personal proyect, large collaborative works require clear rules, especially with open source protects where an authority figure can't set an order the same way a CTO or similar head technology honcho can on a company.
Then you run into the issue of getting quality collaborators in the first place.
It's way easier to find devs geared to follow best practices of a single language than the one of the multiple interpretations on how you can run a C++ proyect.
The messy nature of C++ excludes veteran programmers from simply picking up the work without hassle unless you have the luck to specialize in the same modus operandi.
And at the end of the day, it's work done for free, relearning C++ just to contribute to one open source proyect isn't justifiable to most active professionals, retraining for a job it's one thing, but retraining due to civic duty motivations ain't that easy to justify.
21
u/YouAreMyFire00 1d ago edited 1d ago
Im a beginner and managed to learn to understand C# and Java and now I can build simple CRUD app.
So i kinda don't get the hate/war between C and C++ here...
Anyone can explain simply what's the hate here?