5 ms·
AFAIK Rust is the only language that offers memory safety without garbage collection.
by whyever 12y ago
AFAIK Rust is the only language that offers memory safety without garbage collection.
- st3fan 12y agoSwift
- dbaupp 12y agoReference counting is just another form of garbage collection, http://www.cs.virginia.edu/~cs415/reading/bacon-garbage.pdf http://www.cs.virginia.edu/~cs415/reading/bacon-garbage.pdf
- fanf2 12y agoWhat about Ada?
- whyever 12y agoI'm not sure about Ada, because I never used it, but it seems to have some lifetime checking comparable to Rust's borrow checker. However, it also seems less powerful (in Rust you can specify the lifetime explicitly if need be, in Ada it seems you would have to give up safety).
- _pmf_ 12y agoC++11's std::unique_ptr and std::shared_ptr are also nice features. Does Rust provide more guarantees?
- deleted 12y ago[deleted]
- dbaupp 12y agoRust provides memory safe versions of them; e.g. using a unique_ptr after moving it leads to undefined behaviour. Rust also allows 100% safe references into the memory owned by those types (no possibility of accidentally returning a reference into memory that is freed). Lastly, Rust's type system actually allows 'this value must be kept local to a thread local' to be expressed, meaning there are two shared_ptr equivalents: - Arc (Atomic Reference Counting), which uses atomic instructions like shared_ptr - Rc, which uses non-atomic instructions, and so has much less overhead. Rust also has move-by-default semantics, so there's no extraneous reference counting due to implicit copying. (Which is particularly bad with the atomic instructions of shared_ptr.)