‹ BackHN Continuity

Thread

Deterministic Core, Non-Deterministic Shell

60 points · 17 comments · brandon_bot

  1. Leftium · · focus · HN ↗
    I think actions vs calculations is a better framing here. It's not just about avoiding imperative code or nondeterminism. It's about being extra careful with actions because the order and number of times they run matter.

    Here is an example of a calculation written imperatively. It remains easy to reason about because the actions don't leak out of the function:

        function add(ns) {
            let total = 0
            for (const n of ns) {
                total += n
            }
            return total
        }
    
    On the other hand, a deterministic state machine like `a = AddMachine` is harder to reason about because it still matters how many times the action `a.transition(1)` is called. (Note it is possible to implement the state machine as calculations.)

    <a href="https:&#x2F;&#x2F;ericnormand.me&#x2F;podcast&#x2F;what-is-an-action" rel="nofollow">https:&#x2F;&#x2F;ericnormand.me&#x2F;podcast&#x2F;what-is-an-action

    <a href="https:&#x2F;&#x2F;livebook.manning.com&#x2F;book&#x2F;grokking-simplicity&#x2F;chapter-3&#x2F;page_52" rel="nofollow">https:&#x2F;&#x2F;livebook.manning.com&#x2F;book&#x2F;grokking-simplicity&#x2F;chapte...

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.