AI / Apache Burr Interview questions
Why is Burr’s State object immutable?
Immutability makes every state transition traceable. Because state.update(...) and its siblings always return a new State rather than mutating the old one, the docs describe it as behaving "a bit like" version control’s commit/checkout/merge cycle: before an action runs, state is subset down to only the keys it reads; after it runs, its written keys are merged back into the original state to produce the next commit.
That property is what makes debugging, forking, and parallel/recursive execution safe. If two parallel branches both held a reference to the same mutable object, one branch’s in-place edit could silently corrupt the other’s view. With immutable state, each branch just gets its own snapshot, and a state that was serialized at step 12 can always be reloaded and replayed later without racing against whatever the live process is doing.
The tradeoff is discipline: calling state.update(foo=bar) without capturing the return value is a silent no-op, which is a common first mistake.
More Related questions...