With a bit of fiddeling you can use every kind of bracket to basically make function calls in c++
Here are the links to the snippets, all compile and run
Rust: https://godbolt.org/z/bM3d7bG14
With a bit of fiddeling you can use every kind of bracket to basically make function calls in c++
Here are the links to the snippets, all compile and run
Rust: https://godbolt.org/z/bM3d7bG14
I asked the other day in another thread about hating on C++ what makes C++ so bad and never got an answer.
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
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.
class A { int foo; }; class B : public A { int bar; }; B b; A a = b;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