Immutable.js isn't the only library out there that does what it does. While it is unique in its approach to handling immutable data, it's never a bad idea to compare one library with another. What, exactly, are we comparing it with, though?
Other libraries similar to Immutable.js
What are we comparing?
There's no point in comparing a library such as Immutable.js with something that has no notion of functional programming or immutability. For instance, Angular is a framework for building applications, and observing changes in state is a core pattern. This is something that Immutable.js doesn't do. Comparing Immutable.js with something such as React doesn't make much sense either. Despite the fact that React honors concepts such as avoiding side-effects, we wouldn't be comparing apples with apples, as they do different things at different levels of abstraction.
Some criteria that you would use to compare Immutable.js with other libraries include the following:
- Is it a low-level library?
- Does it support the notion of immutability?
- Does it have the concept of collections?
- How large is the API compared with that of Immutable.js?
- How efficiently can it handle immutable data?
Lodash is a good bet
Lodash is a popular utility library that does a lot of the same things as Immutable.js. It supports the notion of immutability and avoids side-effects. It also supports the concept of collections. Its approach to efficiency is different from what Immutable.js does, but it's there. It might have a larger API than Immutable.js, but it's not that much larger.
The two libraries differ greatly in their overall approach and design, but they're comparable in the aspects that matter. Learning Lodash before switching to Immutable.js isn't a total loss and vice versa. You won't know which libraries work best for you until you write code that uses them.
We'll start writing Immutable.js code in a moment.