Building a Better Web
June 19–20, 2017: Training
June 20–22, 2017: Tutorials & Conference
San Jose, CA

Immutable data structures for functional JavaScript

Anjana Vakil (Mapbox)
3:35pm–4:15pm Wednesday, June 21, 2017
Future JS & Functional
Location: 210 BF Level: Intermediate
Secondary topics:  Functional Programming (Elm, ClojureScript, Erlang), JavaScript frameworks and libraries (Angular, React, Ember, Vue, etc.), JavaScript/ES6
Average rating: ****.
(4.82, 11 ratings)

Who is this presentation for?

  • JavaScript (Node) developers and functional programmers

What you'll learn

  • Understand the core concepts underlying implementations of persistent data structures in functional languages such as Clojure as well as structural sharing with trees
  • Explore two popular libraries for functional programming with persistent data structures in JavaScript: Mori and Immutable.js

Description

Functional programming has been gaining popularity in the JavaScript community, and for good reason: rejecting side-effects and mutability (in-place changes to data) helps avoid a lot of headaches.

But even if you refuse to mutate objects, you’ll still need to deal with transformations to data. In a purely immutable world, this means 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. By making immutability efficient, such data structures are fantastic for functional programming and play a central role in functional languages such as Clojure.

Anjana Vakil explains how the concept of structural sharing makes efficient immutable data structures possible and demonstrates how they work under the hood. Anjana also offers an overview of two libraries—Mori and Immutable.js—that let you easily take advantage of these remarkable data structures in your JavaScript code. You’ll leave armed with a deeper understanding of how immutable data structures work and the practical knowledge to leverage them in your own functional JavaScript projects.

Photo of Anjana Vakil

Anjana Vakil

Mapbox

Anjana Vakil suffers from a debilitating case of curiosity, which led her from philosophy to English teaching to computational linguistics to software development. As Engineering Learning & Development Lead at Mapbox, she can usually be found in San Francisco; that is, when she’s not traveling the world trying to share the joy of programming and make the tech community more diverse and accessible. Talk to her about functional programming, language design and implementation, and speech technology, and ask her about Mozilla, Outreachy, and the Recurse Center.