Hacker News new | ask | show | jobs
by bluGill 5 days ago
Which is stupid, if someone has code that doesn't violate the contract why force the runtime check. Either you don't turn them off, or you don't care. Forcing your preference on others is bad.
1 comments

> “why force the runtime check”

I mean, gestures broadly? Checks are cheaper than ever and prevent all sorts of issues that can happen over time. Your code doesn’t violate the contract today, on your machine, great. It’s very possible, even likely, someone will come along later in time and change something which might break that.

Even Rust, which is all-in on safety, has escape hatches to turn this shit off.
Not in the same way contracts were/are able to be disabled. There's no command line flag or build mode to disable the borrow checker or assert!()s or bounds checks or etc. There is debug_assert!() which is disabled in release mode, but the original code author decides when and where to use that.
Actually there literally is a command line flag to disable the borrow checker, since it’s slow. But since it’s a purely compile time feature the final binary is the same either way, you just don’t know if your code is junk until you turn it back on.
> Actually there literally is a command line flag to disable the borrow checker, since it’s slow

I think this is misleading? There is a flag to disable the new borrow checker implementation (Polonius) since it can be slower than the old one, but that flag does not disable the old borrow checker implementation.

Furthermore, that flag is nightly-only right now since Polonius has not been stabilized yet. I wouldn't be surprised if it were removed if/when Polonius is stabilized.

IIRC the devs' decision to not have some kind of "lenient" mode was intentional, so I'd be rather surprised if there were an official way to completely disable the borrow checker.