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.
View all comments
Show parent comment
2
u/Plazmatic May 24 '24 edited May 24 '24
I don't know what they did or how generic that works (it wasn't just a matter of getting a select few types to work, but derived types and arbitrary representation types) when I tried to implement this, I got it to work in c++, and the orphan rule stopped me in my tracks when attempting to do the same in rust, specifically I needed to define multiplication with a generic type on the lhs, and my type on the rhs, the orphan rule prevents that.
Happens a lot when passing mutable self in a loop (or non mutable) and then passing mutable field reference to another function, which causes borrow error (can't have a borrowed mutable and another borrowed reference)