You Must Fix Your Asserts (Zig)

Programmers are fighting over a tiny safety check that could wreck your app if ignored

TLDR: Loris Cro says disabling app safety checks in release builds is a dangerous habit because failures can turn into weird, silent bugs instead of obvious crashes. Commenters were split between cheering the tough-love stance and arguing developers should choose their own style of checks.

A seemingly nerdy post about a coding safety check turned into a full-on "are we being reckless in production?" brawl. Zig developer Loris Cro argued that turning off asserts — little built-in sanity checks that scream when something impossible happens — is not just questionable, but an "irredeemably bad practice." In plain English: if your app hits a condition that should never happen, Cro says it should crash loudly instead of silently wandering off into chaos. And yes, the comments immediately split into tribes.

One camp basically yelled, "finally, someone said it." They argued that in giant codebases, these checks are the only thing standing between a small mistake and a nightmare bug hunt. One commenter pushed fuzzing — automated random testing — like it was the superhero sequel this article forgot to announce. Another dusted off old-school software doctrine, insisting asserts should follow Design by Contract, a formal way of saying, "stop sprinkling them around like confetti."

But the pushback was spicy. Some readers said this is being overdramatic because Zig’s built-in assert is only one kind of assert, and if developers really want checks that vanish in release versions, they can just make their own. Then came the war story: a commenter described a massive C++ company that relied almost entirely on checks in testing, barely any unit tests, and kept promising production safety was coming "soon" — a timeline so cursed it practically became the thread’s punchline. The vibe was part safety lecture, part workplace trauma dump, and part group therapy for programmers haunted by bugs that "should never happen."

Key Points

  • The article defines assertions as code statements that encode facts about program state, such as preconditions, postconditions, and invariants.
  • It states that when a language’s type system can enforce a constraint directly, that approach is preferable to using assertions.
  • In Zig, assertions are built on the `unreachable` language feature, which marks invalid or impossible code paths.
  • Zig’s `std.debug.assert` is implemented by calling `unreachable` when a condition is false.
  • The article explains that in Zig’s checked build modes assertion failure causes a panic, while in unchecked modes it can result in undefined program misbehavior rather than a guaranteed crash.

Hottest takes

"irredeemably bad practice" — Loris Cro
"you can pretty easily have a different kind of assert that disappears in release builds" — jmull
"production asserts... 'soon'" — moleperson
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.