Immutability remains one of the great dividing lines between procedural languages like C and C++, and functional languages like Haskell and Clojure. While many other traditionally functional features — such as higher order functions, lambda expressions, and lazy evaluation — have made their way into C++ over the past decade, mutability remains at the core of the language.
This talk aims to offer a fresh perspective. Immutable data structures offer a solution to a challenge many developers face every day — safety in a multithreaded environment. Unlike other data containers, they are thread safe by design and allow processes to be optimised through the sharing of data, with no risk to one another. They also make it easier to reason about and debug code, as the state of the program and its environment at each stage is persisted.
After discussing the unique value that these data structures can bring, we will turn to the traditional drawback of immutable data — performance. We will examine some of the modern data structures developed for other programming languages, such as Clojure’s persistent vectors, and learn how these challenges can be overcome, sometimes to the point where what once was a weakness becomes a strength.