Interesting,I absolutely despise C++, and I find rust to be incredibly nice (though admittedly, I'm a neophyte, I've barely had to use lifetimes, so I may be unaware of my own lack of knowledge).
The complicated lifetime stuff is pretty rare to run into unless you are doing some tricky things, like custom zero copy parsers or data structures or whatever.
The most important tricks I've learned are:
- Return types should usually be owned values, input types should often be references (or AsRefs). "Be explicit in what you return, and general in what you accept".
- If I'm going to be pointing into an array, its often easier to just pass around indexes instead.
Yeah I learned to return values and accept references very quickly, had to entirely refactor my learning project a day or so into it, but that was for the best.
So to be fair, I haven't used a lot of C++, but what I have has been unlikeable.
I'm a pythonist most of the time, although I've done a not insignficant amount of work in C, but I like high level languages more, and C++ feels like the worst of all the worlds. It is complex and bloated (templates) and magical and all kinds of things. I think I summed it up one day by saying that, as a newbie to C++ my frustrations with the language were summed up by a 0 argument object constructor having no parenthesis if it was stack allocated, but heap allocation or arguments require parens, because the 0 arg constructor would conflict with a function prototype if it had parens.
There's so much bloat and cruft and oldness that the language has baked in inconsistencies and gotchas and so much stuff (which of the 12 different kinds of pointers should I use) that it is horrible to learn.
Rust on the other hand has complex semantics, but they are well defined, sensible, and logical. Sure I sometimes want to smack the borrow checker, but the reason why isn't "someone made it this way before I was born and now I'm stuck with the results".
I need to write C++ every now and then and I don't dislike the modern C++ itself, but the tooling is a bit rough to use.
Getting dependencies from the system is a big PITA and the build tools, as in cmake, seem to require as much knowledge as the language itself.
Having a C++17 with a tool like Cargo building static binaries and just the right versions of the libraries would make my life with the language much easier.