Remix.run Logo
prollings 4 hours ago

Rust requires discipline too. I can go around using Arc, Rc and .clone() everywhere without upsetting the borrow checker, I can use let mut a bunch and pretend if, match, etc. aren't expressions. This results in worse code, and Rust didn't stop me.

The borrow checker prevents a set of errors from being possible, but it doesn't prevent bad code from being written.

self_awareness 4 hours ago | parent [-]

It would be easier for you to argument that the user is expected to have discipline to NOT use "unsafe" keyword in all functions.

Because a lot of mechanisms actually still have guards in runtime. And using .clone() on Rc/Arc is actually the idiomatic/preferred way of evading the borrow checker if we can't design the data structure in a different way.

It's a big difference between cases when you need to spend brain energy to find ways to "out-smart" the compiler, and spend brain energy to "fit into the proper set of assumptions" of a programming language.