An unofficial, read-only Hacker News reader.

The need for a formally verifiable mainstream programming language (opens external site)

343 points by todsacerdoti 3 days ago | blainehansen.me | 321 comments on HN

View full thread · View on Hacker News

Comment thread (8)

  1. > People have written TLA+ specs for their software[1] and not have it materially improve the quality or reliability

    That particleDB link is VERY unconvincing. All the folks I know who wrote a TLA+ spec have said that it helped them discover bugs. Just that it was a massive pain to keep maintaining code and spec independently.

    However, I am confused on why new PL is needed. Why not just improve lean and its libraries so that it becomes a standard big-software language like Go/Java/Rust ?

    Replies (3)
    1. >Why not just improve lean and its libraries so that it becomes a standard big-software language like Go/Java/Rust ?

      Lean wouldn't be able to match Rust in performance without a fundamental restructure of its core calculus.

      Replies (1)
      1.   > Lean wouldn't be able to match Rust in performance without a fundamental restructure of its core calculus.
        
        Why so?
        Replies (2)
        1. Two things

          Lean is garbage collected and you don't control the layout of types in memory (and everything is boxed)

        2. To support in-place mutation and avoid unnecessary memory allocation, it would need some form of linear/uniqueness types, so the language can know when no other references to a type exist so it can be updated in place via mutation. Right now Lean achieves decent performance via https://xnning.github.io/papers/perceus.pdf , but it can't match what Rust can achieve.
    2. There's another alternative - let most of the spec be derived from the code. Verus for example allows you to wrap your code in a verus!() macro and get a lot of the work for free and guaranteed to be in sync with the code. Even without any custom proofs, just that part provides a no-crash guarantee. (You still need to do some work though - it's not free)
      Replies (1)
      1. The normal pattern is that the spec is shorter than the code, and therefore easier to get correct. That's why it's useful. Deriving the spec from the code therefore seems like going the less-useful direction.
    3. Languages like TLA+ lay at the opposite end of the spectrum of how programs can be optimized. The more space you leave for optimization, the larger the search space becomes in evaluating the TLA models. The smaller the space you use for the models, the more constrained your optimizations become. It seems as though the two can’t be combined without finding an appropriate balance point at which point you’d probably have something very similar to existing languages.