Index

On asserts

It’s common to see C/C++ projects disable asserts when building releases. The book Cryptography engineering argues that it’s a mistake: production code is exactly the place where assertions are most needed. That’s where things should never go wrong, and if they do we shouldn’t sweep the problem under the rug.

Patrick Wyatt an ex-Blizzard developer who worked on the early Warcraft, Diablo, and StarCraft came to the same conclusion after working on Guild Wars: it’s OK to “waste” a little bit of CPU to make sure production code runs correctly.

Assertions aren’t that expensive, we really shouldn’t remove them in production. These days speed is rarely an issue while correctness is always an issue.