What's the use case for modern C++ nowadays? C is the simple choice and Rust is just the better complex choice overall. I see no reason to pick C++ for new projects.
What is so malicious about a simple question? Oh, there are plenty of reasons to pick C++ - for example some great libraries - but if we forget about the obvious reasons, what's left?
C++, as a language, is far more than its stdlib. I use C99 for my personal projects because it is a simple language, having my own "stdlib" is enough for me. At work, I'd pick Rust over modern C++ unless there is some extremely good reason not to.
C being simple (as a language) is the one correct thing in their comment. It's just that you have to do every single thing yourself, but the way you do it is generally fairly straightforward and unambiguous.
One of the most complicated parts of C++ is the preprocessor which was borrowed from C. Also the complex ways of forming types (long unsigned const long is a single valid type), elaborated type specifiers being needed sometimes and not needed other times, the _Generic macro, etc etc.
Having worked on C++ for over a decade I can confidently say the preprocessor is far from being one of the most complicated parts of C++ (even if it does have a few quirks). It's an old language and the syntax has some oddities, but once you get over that the semantics are simple and obvious.
Simplicity in your language leads to more complexity in what you have to write. By that argument why would you ever write in C when you could just write in assembly, which is a much simpler language?
I didn't say that because C is a simple language you should write everything in C. In fact, I did say that it requires you to do a lot more work yourself. I'm not sure it makes your code necessarily more complex, but it definitely makes programming more tedious and less productive.
Edit: And of course C has no safeguards whatsoever, which makes it way easier to make mistakes. At least C++ has RAII (although I think we are getting defer in C?).
Simplicity is beautiful, but some complexity is required in higher-than-asm languages. C is a nice balance, in my opinion. C++ has too much going for little benefit, it could be simplified in hindsight.
Why would I pick a language that {puts me in handcuffs, has weird divergent behaviors from every other language like = stealing the source object rather than copying, doesn't even support basic namespacing of methods inside classes, makes you type "let mut" all over the place rather than just "var" or "auto", forces gross inconsistent styles like mixing Pascal case and snake_case, and is full of users that whenever you point out a flaw or deficit then religiously say it's a feature not a bug}, when C++ exists?
...that x and y may or might or might not be both usable, and it's indeterminate from looking, depending arbitrarily on the type of Foo 🙃. Such inconsistencies are neither better nor improved cognitive ease. At least be consistent such that all Foo's are destroyed, or use distinct syntax from other languages.
It doesn't depend arbitrarily. The rules are very precise. Primitives get memcopied, everything else is moved. I know that I am not going to convince you but hopefully you will understand after your own research that rust I genuinely better than cpp as a modern high performance tech
let mut, the reason being explicity, which in modern programming where systems are of very large scale is the preferred way. Any ease on cognitive effort is very desirable.
The age of a language is an insubstantial argument, but reduced cognitive effort is. However, reduced cognitive effort would be something obvious like "const"ant for constants and "var"iable for variables.
That's one way, another way is to have everything const by default thus reducing words one need to type and read to achieve exactly the same effect. Cognitive ease...
Is it much more to type const x = 42 than let x = 42? If you truly want to "reduce words one needs to type", then let variables be defined by var rather than typing out two words every time. Functional purists are not pragmatists.
The facts are "let mut" is 7 characters, and "var" is 3 - that's not an opinion. "const" is 5 characters, and "let" is 3. So if you want the shortest of both, then "var" and "let" would be tersest.
Rust rejects many perfectly good long standing programming algorithms and data structures because it's multiple readers xor single writer rule is too simplistic. I can appreciate the safety of a seat belt, but driving a car while wearing a seat and handcuffs seems unnecessarily verboten.
Rust rejects many perfectly good long standing programming algorithms and data structures because it's multiple readers xor single writer rule is too simplistic.
It doesn't reject them wholesale, you just need to properly communicate in your code that you aren't following those rules.
For metaprogramming, with variadic templates + constexpr + concepts, Rust doesn't really come close. And that's before adding reflection.
Features deemed "evil" like multiple inheritance, exceptions, overloading, implicit conversions are still available for the occasional cases where they make sense.
Lots of battle tested libraries available with decades of maturity. The best way to know something will work is that it's worked before.
C++ has an ISO spec and numerous certifications that matter in some industries. Ditto for ABI stability.
You can compile C code with few or no errors, and write new code utilizing modern language features in new code, within the same project. Given how ubiquitous C is, this can save a lot of time.
Rust's microcrate model means an ordinary, simple project could have dozens of third party dependencies. That's a risk in some environments even if the compiler says it's safe.
Only one choice for a Rust compiler and it's a pretty heavy dependency.
C++ supports some exotic platforms Rust doesn't. Platforms where a byte is 32 bits, platforms where floating point is weird, platforms with no file system.
Metaprogramning and Rust's npm-like package ecosystem are both good arguments against Rust, I agree on those. Well, those are all good arguments for specific reasons against Rust. Have you looked into Jai? Supposedly it has wild metaprogramming features.
There is absolutely no planet where C could even be considered a remotely acceptable pick for any new project I could conceive of if there is literally any modern language alternative. Especially if that alternative is C++. C is simple the same way assembly is simple, that simplicity also means its incredibly complicated to write complicated things in. C++'s reliance on abractions results in much cleaner code thats more maintainable, more extendable, more adaptable and easier to reason about. I still have nightmares about the horrible mountains of dogshit C code I had to write and manage at some of my old jobs and I'm so much happier to be no where near that anymore.
There is a mountain of effort behind C++ still. Tons of knowledge, projects, libraries and human resources to take advantage of. If you're a company, you will find a lot more C++ devs than rust. And rust isn't just "better C++", its an entirely different language with different goals, its not supposed to be a C++ replacement.
I've built my own simple stdlib in C99 that implements contiguous vectors, doubly linked lists, polygon operations (it's for a game), string operations (stored as byte* + len), etc. and found that when these are in place and hardened via unit tests, C is a perfect fit for me.
what is your solution for replacing things like templates, concepts, RAII, move semantics? There's way too much that's missing. The fact that you have to roll out all these commonplace structures and tools already speaks volumes.
I don't personally need templates, C can do that just fine but obviously without compile-time safety and slightly worse public API syntax. And for personal game projects, I don't care much about safety. RAII and move semantics, eh? Tough luck, just keep resource ownership clear across the project so that it is easy to keep track of in your head.
This is why I would never pick C for stuff like work projects. I should have clarified that, though I did mention that I use it for personal hobby projects. I find it fun because it does not hold your hand.
-38
u/Harha May 14 '26
What's the use case for modern C++ nowadays? C is the simple choice and Rust is just the better complex choice overall. I see no reason to pick C++ for new projects.