253
C++ superiority
(lemmy.nz)
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
I asked the other day in another thread about hating on C++ what makes C++ so bad and never got an answer.
There are lots of ways to write C++ code that looks perfectly reasonable but introduces horrible undefined behaviour. You need to be aware of lots of edge cases all the time and you will still make mistakes that can introduce difficult to trace bugs. One of my personal favourites is object slicing.
Looks OK? Well,
anow only contains theApart of the object. The fieldbaris lost in the assignment. There are reasons for this behaviour but its a sharp edge nonetheless.These kinds of problems are numerous and you have to keep them in mind while programming C++. Some people don't mind it but many do. Static analysis tools that can catch many of these errors exist, but I understand people who say they don't want to deal with that and rather use a language where these kind of errors are not possible. Personally, I would also discourage people from starting new C++ projects today if they can avoid it.
I don't really know myself, probably the many footguns and complexities. Like taking a reference to a value in a vector and then resizing the vector, boom undefined behaviour. There a re a lot of things like this. Maybe also the verbosity and multie ways to do things. Look at the linked code, there is a lot of overhead to the function definitions, sure there is a point to all of it and I put it there for a reason, but to people less familiar to the language it is probably quite offputting.
Personally I like the language, second only to rust for me
If you have a couple of hours, and can stomach the AI art, then this video covers a lot of the niceties of C++:
https://www.youtube.com/watch?v=7fGB-hjc2Gc