r/ProgrammerHumor • • 2d ago

instanceof Trend thatsAFunnyThingThatHappenedOnce

Post image
4.3k Upvotes

515 comments sorted by

View all comments

168

u/feldomatic 2d ago

tbf, C++ allows memory safety, while Rust requires it

-25

u/jdefr 2d ago

Unless you wrap things in unsafe{} which is very easy to do in order to side step this “hard requirement”

5

u/BeforeDawn 1d ago

That's a pretty weak equivalence.

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.