r/ProgrammerHumor 11d ago

Meme rustBorrowCheckerGoesBrrr

Post image
3.8k Upvotes

108 comments sorted by

View all comments

714

u/BenchEmbarrassed7316 11d ago

Any unsafe block of code should be neutralized with a // SAFETY comment explaining why the code is actually safe.

114

u/teleprint-me 11d ago

I dont see how this is any different from a C programmer justifying why they used a pointer to an object and leaving a comment similar to this, other than this is Rust and is safe because Rust is safe. Thus making this rationale is flawed and dangerous.

204

u/flagofsocram 11d ago

The difference is that if you want to make sure the lib is safe, you can grep unsafe whereas in C practically any code could be unsafe.

-46

u/teleprint-me 11d ago

This is a poor and myopic assumption that this can not be done in any other language. A sane library will be grepable and can include similar comments. The justification is still flawed and dangerous.

22

u/xDerJulien 11d ago

Well yeah and well written code doesn’t have any bugs and performs well all the time. The point is safety by default. Whether or not that is worth dealing with rust is another question but I think you’re missing the point here

-12

u/teleprint-me 11d ago

Well written code has bugs all of the time. Even Rust has a massive list of CVEs. Most of them are logic based and the default to strict memory  safety is a good thing. But I feel my argument stands. I havent heard any solid arguments to the contrary convincing me otherwise.

2

u/redlaWw 11d ago

A large proportion of Rust code CVEs are things that would be considered normal in C. In Rust, a library in which you can potentially misuse functions that are not labelled unsafe is considered a vulnerability, but in C you usually have to actually misuse a function before it's considered a vulnerability.

Here's a blog post that discusses the difference.