3 ms·
I find immutable state to be useful when appropriate. But sometimes you really do want mutability, and it is a feature. Performance of updating player.coordinat
by IgorPartola 2y ago
I find immutable state to be useful when appropriate. But sometimes you really do want mutability, and it is a feature. Performance of updating player.coordinates, ability to create temporary but potentially complex structures inside the function, lack of need to create a new immutable copy of a bank account’s ledger to add another transaction, all good reasons to allow mutability.
It seems that there are some people who really just think of everything as a state machine and want state transitions to happen only in very controlled and specific ways. And other people seem to focus more on how to organize frequently evolutions of mutable state in a way that makes it easy to reason about. I’m not sure if there is some sort of commonality to these approaches. Different parts of the industry maybe? Different exposure to Haskell?
- mrkeen 2y ago> lack of need to create a new immutable copy of a bank account’s ledger to add another transaction, all good reasons to allow mutability. The immutability kool-aid was already drunk by the banking industry 5000 years ago. That's why you're appending transactions on a ledger instead of mutating bank balances (behind getters and setters, so it's "encapsulated" /s).
- IgorPartola 2y agoSure but your account balance does mutate and so does the length of the ledger. (I know this was sarcasm, but I do think those are important considerations).
- mrkeen 2y agoIf your account balance and ledger disagree, which one is right?