2 ms·
The reddit quote (image, sigh) is right: in Rust `unsafe` has its place. The language has been designed with the escape hatch from the start, so the "safe" subs
by pornel 4y ago
The reddit quote (image, sigh) is right: in Rust `unsafe` has its place. The language has been designed with the escape hatch from the start, so the "safe" subset of Rust is not a complete language. Rust wouldn't get far as a systems programming language if it always had to face limits of the borrow checking model and require the mythical Sufficiently Smart Compiler to magically fix every performance overhead.
Rust still helps ensuring that the "hold my beer" blocks are correct by reducing their scope to a few clearly marked places. This helps focus code reviews and fuzzing. Rust also encourages wrapping of high-risk code in foolproof abstractions, and has universal rules for how tight and robust such abstraction has to be. In a way, Python or Java are also safe abstractions on top of "unsafe" CPython or HotSpot. In Rust this division is just more granular, with the same syntax on both sides.
It's worth remembering that in Rust "safe" refers to Rust's specific guarantees around memory safety and thread safety, but the field of software security is much larger than that. There are lots of possible logic bugs and security issues beyond that, and Rust won't stop you from running `remove_dir_all("/")`.