3 ms·
Firstly, manual memory management is what happens when a C programmer must manually place malloc/free calls within her program. Rust doesn't require any of that
by maxaf 9y ago
Firstly, manual memory management is what happens when a C programmer must manually place malloc/free calls within her program. Rust doesn't require any of that; the compiler determines the right times to allocate and free memory, while requiring the programmer to follow certain design rules in exchange for the convenience.
Second, you're making it sound as if the position Rust (and those who program in it) is somehow undesirable. This state of things is the consequence of an explicit design goal, which was to accomplish automatic memory management without runtime cost.
- varjag 9y agoInteresting; I certainly wouldn't consider C++ constructor/destructor like semantics and manual tracking of object ownership in the code as automatic memory management. But regardless, the point stands. And yes it's a consequence of a design goal, I said as much. The outcome however isn't beautiful enough to feel smug about the rest of programming languages.
- kosinus 9y agoDo you consider C++ RAII as manual memory management?
- mathw 9y agoRust doesn't have C++ constructor/destructor semantics. It doesn't require manual tracking of object ownership. You just have to say when you're passing ownership and when you aren't, and the compiler takes care of the rest. It's automatic memory management without runtime accounting or a garbage collector, which means Rust doesn't need a runtime at all.
- varjag 9y ago> It doesn't require manual tracking of object ownership. You just have to say when you're passing ownership and when you aren't […] Call it whatever you want, but there are languages where you don't have to "pass ownership" manually for every frigging thing.
- iknowstuff 9y agoAnd you won't see them being used for systems programming because of their overhead. So without Rust, we'll be stuck with stupid, avoidable security vulnerabilities at the base of all our software, forever. On top of that, Rust's ownership system also prevents data races and none of those other languages are capable of that.
- creatornator 9y agoI'd say Java, a GC'ed language, is used for systems programming quite often.