3 ms·
> Also, if you want to keep your sanity, you will learn to take ownership seriously. Deciding > what owns what and whether objects will be owned by the scope
by dotancohen 3y ago
> Also, if you want to keep your sanity, you will learn to take ownership seriously. Deciding
> what owns what and whether objects will be owned by the scope (on the stack), be owned by unique_ptr, or
> be shared with shared_ptr is a large part of designing a C++ program.
I would love if you could expand on this. I've much experience with higher level languages such as Python, but as I get into C++ I find these nuggets of advise invaluable.
- brabel 3y agoI've found this Youtube video (and the whole channel) very good to help understanding Rust: https://www.youtube.com/watch?v=TJTDTyNdJdY https://www.youtube.com/watch?v=TJTDTyNdJdY Agree with the quote: that's the biggest challenge with Rust... I have been trying to pretend Rust is like Java and I think that was my big mistake. When you design anything in Rust, even the most basic stuff, you will need to decide "what owns what", unless you clone everything on every usage. Try some very simple code that requires allocation and you will quickly notice that. I am now back at Rust and redesigning all my code to make "what owns what" the first question I ask when writing anything, and that is already being very helpful. But of course: if you don't need the performance of Rust or the small footprint, it's just not worth it spending time on stuff like that can be completely and utterly ignored in any non-systems language.
- dotancohen 3y agoThank you.