5 ms·
I have only dabbled in Rust and have no experience with C++/Java/Go. Can you help me understand how those languages would be more memory safe than Rust? My unde
by LecroJS 4y ago
I have only dabbled in Rust and have no experience with C++/Java/Go. Can you help me understand how those languages would be more memory safe than Rust? My understanding was that safe code was a solution to memory leaks. What’s the benefit to safe rust code if it isn’t getting rid of memory leaks?
- latifk 4y agoBecause memory leaks are memory safe in rust, they just cause a performance hit.
- 3a2d29 4y agoMemory leaks are not memory safety. Memory leaks in all languages are safe, they just slow performance and cause crashes. Rust still memory leaks.
- LecroJS 4y agoThanks. So what does it mean for a program to be memory safe if it can still memory leak? An example or pointing to a resource for further reading would be much appreciated.
- Jtsummers 4y ago> So what does it mean for a program to be memory safe if it can still memory leak? That it's not actually memory safe. Memory leaks are part of memory unsafety.
- Hemospectrum 4y agoThat’s not correct. Memory safety consists of properties necessary for type safety to be upheld. Leaks alone can crash a program but can’t defeat type safety.
- Vecr 4y agoIt prevents data races, use-after-free, double-free, buffer overflow, invalid type punning, etc. You can still do all those things in unsafe code though, and you could in safe code if the unsafe code you depend on (including the kernel) behave/are programmed incorrectly. You can also have hardware issues and stochastic bit flips that Rust and SPARK can't deal with.
- giaour 4y agoMemory safe code does not prevent applications from using too much memory; it prevents applications from accessing the wrong memory (e.g., by using a variable after its underlying value has been freed and the memory reallocated).