Get the latest tech news

What is an invariant? (2023)


I extolled the benefits of programming with invariants in a couple of recent posts. Naturally, I didn't explain what I think when I write invariant. This post fixes that.

a general “ math ” mode of thinking, where you distinguish between fuzzy, imprecise thoughts and precise statements with logical meaning. The bulk of the post describes thesecond bullet point, for which I think I have a perfect litmus test to explain exactly what I amthinking here. The thinking about this invariant was that it simplifies refactors — while in thestatic program it’s natural to talk about “ if on the line X in file Y”, when you start modifyingcode, identity becomes much more fluid.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Invariant

Invariant