I've seen C++ that suffers from exactly those problems too.
It's also a lot easier to hide those problems in C++, and in fact much of the achievable elegance in C++ code relies on the very same features that also tend to obfuscate problems.
I must have had a sheltered existence or something. I work with C and C++ daily. It is definitely possible to write dreadful C++, but I don't recognise that this is the norm, nor worse than C, nor whatever else people keep telling me. People, it has to be said, who mostly don't routinely work with C++. I guess others have different experiences.
The fairest thing to say might be that the languages can each be horrible in different ways. Perhaps some people "get" C and are totally fine with it, but C++ is for them an alien planet with obscure dangers. And vice versa. A mindset thing related to paradigms that one is comfortable with. Or something. Maybe. Don't know. That's pure speculation.
I think it very unfortunate that we have come to such an unhelpfully polarised and entrenched position regarding C and C++. I can't see that ever going away. A pity.
If your organization has no crappy C++ code, maybe you’re the one writing it? ;-)
Kidding aside, I agree, especially about it being a pity that positions are so entrenched. But we should be careful not to pretend that everything is equal. C++ is a much better language overall than C (which says nothing about the quality of C++ code in general). It solves some problems that C doesn’t.
And Rust is a better language than C++ (which is not to say that there aren’t places where Rust is still catching up) - it solves some problems that C++ can’t.
I've studied Rust a bit but can't claim any expertise. I have not found it remotely compelling since I do not have the issues it solves. At the end of the day, embedded code requires unsafe sections of code anyway, so there's that. I also don't relish trawling through fifteen layers of OSS crates to understand what's going on. I do really like the pattern matching with enums (tagged unions), though.
I have observed that C devs love Rust. It's pretty obvious why. What a pity they did not invest a little time in C++ 30 years ago, eh? ;)
4
u/simonask_ Jul 13 '22
I've seen C++ that suffers from exactly those problems too.
It's also a lot easier to hide those problems in C++, and in fact much of the achievable elegance in C++ code relies on the very same features that also tend to obfuscate problems.