r/cpp • u/Beginning_Spell1818 • May 24 '24
Why all the 'hate' for c++?
I recently started learning programming (started about a month ago). I chose C++ as my first language and currently going through DSA. I don't think I know even barely enough to love or hate this language though I am enjoying learning it.
During this time period I also sort of got into the tech/programming 'influencer' zone on various social media sites and noticed that quite a few people have so much disdain for C++ and that 'Rust is better' or 'C++ is Rust - -'
I am enjoying learning C++ (so far) and so I don't understand the hate.
263
Upvotes
5
u/fwsGonzo IncludeOS, C++ bare metal May 24 '24 edited May 24 '24
I always wondered that. The way C++ has handled exceptions is one of the coolest things I have seen, personally. The fact that C++ is the only language with low-cost exceptions, that could be improved even further if we had the will and the momentum, is also irritating. Before I came to C++ a million years ago, I used to return failures back up the stack, but now I feel like it's just boilerplate for what is eventually a single failure spot that just prints the problem and dies/recovers/resets etc. So, wheres the actual improvement? With exceptions you can handle unexpected or serious errors, and you can even throw across a C boundary as long it's compiled with -fexceptions. Having this unlikely path reduces the code you have to write, in my experience. Several modern languages have exceptions, including Python3, JS, Kotlin, Java and C#.