Assertions are pessimistic, assumptions are optimistic (2014)
blog.regehr.org
blog.regehr.org
I toyed with them while learning some unsafe Rust by calling unsafe Windows APIs. Sometimes there were obvious relationships between function parameters and return values that my code couldn't know because the Windows API was an opaque FFI to C. Like if I ask a Windows API to fill an 8-element array, my code can assume it returns an int <= 8 instead of considering INT_MAX as a possibility.
But anything more advanced like assuming that an array's values are sorted seemed questionable. At worst, it looked like LLVM preserved expensive assumes even if they weren't useful to the optimizer.
Since it was a toy project, I didn't care. It's neat to tell my code facts about the world and imagine that a perfect code optimizer can use all those facts. Even if there's a C API in the way.
https://doc.rust-lang.org/core/hint/fn.unreachable_unchecked...
Assertions Are Pessimistic, Assumptions Are Optimistic (2014) - https://news.ycombinator.com/item?id=9828805 - July 2015 (4 comments)
It's not a new idea, this has been integrated into programming languages before, notably Eiffel (1985)
Turning off assertions is effectively a "you are no longer bound by this contract" action.
If management feels toilet cleaners arent adding value, fires them, and then shit hits the fan, the system works as intended.