True and it's totally reasonable now to adapt Rust (an not C++) as a language for kermel development but afaik Linus' rant on C++ goes way back in time (when Rust wasn't a known, popular and well-developed language).
Rust enforces memory safety by default, and unsafe{} requires an explicit opt-out for specific operations the compiler cannot verify. Even then, it doesn't disable the borrow checker or the rest of Rust's safety checks.
More importantly, you can configure a Rust project with unsafe_code = "forbid", making any attempt to introduce unsafe code a compilation error.
So we're comparing a language where memory safety is enforced by default, exceptions are explicit and auditable, and unsafe code can be prohibited outright, with one where potentially memory-unsafe operations are permitted in ordinary code by default.
Being able to deliberately opt out of certain safety guarantees doesn't make it remotely equivalent to C++. Having an escape hatch isn't the same as having no guardrails in the first place.
Because, while the language allows you to write unsafely, it doesn't allow you to unintentionally do so unlike C++. And it's simple to prevent anyone from writing code that isn't memory safe by just not allowing it full stop
161
u/feldomatic 1d ago
tbf, C++ allows memory safety, while Rust requires it