3 ms·
Mutability introduces an entire class of bugs and is slower to execute. If don't mutate something, it's almost always frictionless and better to make it immutab
by echelon 5y ago
Mutability introduces an entire class of bugs and is slower to execute. If don't mutate something, it's almost always frictionless and better to make it immutable.
There is tooling around immutability and a whole host of compiler optimizations. The resultant code is far less error prone.
Do you feel the same way about static typing?
- jraph 5y agoImmutability may enable compiler optimizations, but it also requires copying things around or applying clever tricks so performance isn't too bad. There are times for immutability, and times for mutability. You have to be careful for different things.
- beebeepka 5y agoNo. Proper theology demands that you must go with the latest react trend and discard everything else until they change their mind again and generate a ton of blog posts teaching you what was rejected a couple of years ago.
- orf 5y agoIt’s not so straightforward as “it’s slower to execute”. Often excessive copying of immutable objects instead of mutating them means code is slower, especially in JavaScript.