site banner

Friday Fun Thread for January 31, 2025

Be advised: this thread is not for serious in-depth discussion of weighty topics (we have a link for that), this thread is not for anything Culture War related. This thread is for Fun. You got jokes? Share 'em. You got silly questions? Ask 'em.

2
Jump in the discussion.

No email address required.

thus far I find it's constructs around "borrowing" references silly and contrived, especially in light of being able to assign unsafe sections of code that ignore it's memory safety rules. I guess it assumes you'll be responsible with that

That's pretty much the idea. Rather than C(++) where unsafe memory access can happen anywhere, in Rust the strategy is to limit the unsafe scope so that you can focus really hard on getting those parts right.

It doesn't seem like a half measure to me, though. The reality (for better or for worse) is that when you're doing systems programming you're going to have to access raw memory sometimes (e.g. memory mapped registers for devices). So they have to have some kind of escape hatch where you are allowed to do things that the compiler can't verify are safe. Maybe that doesn't look exactly like what Rust has, but it still has to exist somehow or other.

Also note that unsafe blocks don't completely let you off the hook for Rust's memory rules. For example, you still can't take two &mut references to the same thing, nor can you use a variable after you transfer ownership to another function. So it's not a complete free for all or anything.