Skip to content
0:00 / 0:00

#immutabledatastructures#persistentdatastructures#hamt

Anjana Vakil: Immutable data structures for functional JS | JSConf EU

JSConf

286K subscribers • 28 videos on Hallway

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • Presented by Anjana Vakil

Intermediate. Assumes working knowledge.

325K views9 years ago2 recommendations

Programming languagesComputer scienceFunctional programmingJavaScriptData structures

Anjana Vakil explains how persistent data structures like Hash Array Mapped Tries enable efficient immutability in functional JavaScript.

2017.jsconf.eu/speakers/anjana-vakil-immutable-data-structur… Functional programming has been gaining a lot of popularity in the JS community, and with good reason: rejecting side-effects and mutability - in-place changes to data - helps avoid a lot of headaches. But when you refuse to mutate objects, you have to create a whole new object each time something changes, which can slow things down and eat up memory, making functional programming seem inefficient. That’s where immutable data structures come in - to save the day, and time and space! Also called “persistent data structures”, they help you efficiently make new “modified” versions of immutable objects, by reusing parts of the old object that you don’t need to change. In this talk we’ll take a look at how these data structures work, why they’re fantastic for functional programming, and how we can easily use them in our JS code thanks to libraries like Mori and Immutable.js.

Why it's here

2 people recommend this

What people say. Recommended as an easy-to-understand introduction to Hash Array Mapped Tries and immutable data structures.

u/a3th3rusin r/ProgrammingLanguages • Recommends

On “What are some of the state of the art data structures in function language implementation?”

An easy-to-understand introduction to Hash Array Mapped Trie (HAMT): [video

u/aaaaargZombiesin r/typescript • Recommends

On “How to prevent a reference passed being one that can be modified?”

You can use `Object.freeze` as others have said if you want to throw when someone modifies the reference or you can use `as const` to get linting from TS. If you want immutable data it might be worth reaching for a library that creates a proper immutable data structure as they are much more efficient than just copying the array on each interaction - though this is fine if you are dealing with small arrays. If you're not aware of immutable data structures this talk is an excellent intro link to this video