• efitz an hour ago

    I’m not sure that I agree with the article.

    In the course of my work, I think of an invariant as a state that must hold true at all points during the software’s execution.

    For example, “port xxx must never accept inbound traffic”.

    I don’t think of invariants as mindsets; I think of them as runtime requirements that are observable and testable at any point during execution, and whose violation is an indication that some assumption about state that the proper execution of the software depends on, no longer holds.

    Maybe a good analogy would be “a runtime assert”.

    • JadeNB an hour ago

      > In the course of my work, I think of an invariant as a state that must hold true at all points during the software’s execution.

      That seems quite close to the author's answer:

      > Perhaps it’s time to answer the title question: invariant is some property which holds at all times during dynamic evolution of the system.

      • swatcoder 28 minutes ago

        Indeed, but the author works through a deeply idiosyncratic train of thought before getting to that, and then quickly continues with some creative analogizing about how the idea of an invariant might be applied at other scales.

        For an essay titled "What is an invariant?", it doesn't really focus on answering the question at all and so the GP's failure to spot the traditional answer is pretty reasonable. A more fitting title may have been something more like "Invariants in software system design" -- better framing that it'll be a survey of examples and their rationales rather than an analysis of invariants.

        • MontagFTB 40 minutes ago

          For data structures, an invariant is something that must hold true at the end of all its public APIs. For example a doubly-linked list may have to break invariants around its pointers while in the middle of a splice or insert. But at the end of those public routines they must all be valid and conformant to the type’s requirements.

          • lupire 31 minutes ago

            Right. A "system" is the observable parts.

            If you have a good wall of abstraction, you have freedom in the internals and security in the observables.