Reputation: 2332
What motivates the increasing usage of immutable data structures such as those provided in ImmutableJS and SeamlessJS?
I know there are debugging and memory benefits. I'm interested in uses across the JavaScript stack, but I'm also thinking of common front-end tasks that are made easier to work with or reason about.
Upvotes: 1
Views: 110
Reputation: 76297
There are at least three benefits:
Regardless of whether it is frontend or backend work, it can simplify your logic and work process significantly. If the app has a bug, then anything you can rule out, including the inadvertent modification of some logically-immutable data structure, can help.
It can improve runtime performance when you clone objects containing them.
I doubt these specific libraries actually use this, but immutable data structures can sometimes have better implementations. Hash tables can utilize perfect hashing, and balanced trees can be replaced by sorted arrays.
Upvotes: 4