21 ms·
Yeah! If your mutability is completely limited to the scope of your function, then you should be fine. If your programming language takes the power to mutate a
by sink 11y ago
Yeah! If your mutability is completely limited to the scope of your function, then you should be fine.
If your programming language takes the power to mutate away from you then you have even less to worry about: You don't have to rely on self-discipline to not write a bad program, the compiler tells you it's not good.
Even in really small functions, with tiny scopes, I think reasoning about mutation takes a tidy mental toll. You can express about almost everything you need (well, I don't really know you or what you are programming) with maps and folds and recursion.
In object oriented languages the traditional belief has been that encapsulation with privacy modifiers and getters and setters is sufficient to make well behaved programs. I don't think that goes far enough. I think that to reason about programs effectively you need some sort of immutability guarantee.