Hacker News new | ask | show | jobs
by juxtaposec 562 days ago
Memory safety is an umbrella term for many properties of a programming language. Unfortunately, as have been pointed out by many, the exact meaning of this term is actually determined by Rust. In the past, Rust considered "no memory leak" as one of the memory safety properties, but some difficulties made it no longer part of Rust's guarantees.

IMHO, there are two undisputed properties that definitely should belong to memory safety, and they are good enough to spot "unsafe languages".

- Every memory access should be valid. You cannot read or write a pointer that is uninitialized, that points to a freed object, or that is beyond the boundary of the array, etc.

- Every memory access should be properly synchronized. This implies strictly controlled mutability.

These properties are _enforced_ by the compiler. In safe Rust, you cannot create a dangling pointer and dereference it. You also cannot create a data race by accident. But in C, C++, Zig, you can. In this sense, languages with managed memory are usually automatically memory safe.