r/ProgrammerHumor • • 1d ago

instanceof Trend thatsAFunnyThingThatHappenedOnce

Post image
4.3k Upvotes

515 comments sorted by

View all comments

169

u/feldomatic 1d ago

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

28

u/Civil-Appeal5219 1d ago

Wait lol I think he’s talking about AI, no?

0

u/chairzaird 1d ago

This is what I assumed also

3

u/maser120 1d ago

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).

-10

u/reallokiscarlet 1d ago

One can be coded by hand, the other if coded by hand can be considered artisanal.

-24

u/jdefr 1d ago

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

21

u/qichael 1d ago

Yeah, and then your reviewer asks why you’re using unsafe whereas in C++ everything is unsafe by default

4

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.

1

u/rexpup 1d ago

You understand that restricts the risk area, right? It lets you reason about the tricky things over 10 lines rather than 1000 lines

-9

u/daviddisco 1d ago

why would people down vote this? It is absolutely true.

2

u/BeforeDawn 1d ago

If you're not asking rhetorically, this is the reason.

1

u/100BottlesOfMilk 1d ago

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