Immutable Data Structures in C++

Alistair Fisher

⏱ 90 minute session
beginner
intermediate
advanced
16:00-17:30, Thursday, 18th April 2024
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.

🏷 functional
🏷 data structures
🏷 thread safety
🏷 immutability

Alistair Fisher

Alistair Fisher is a Team Leader at Bloomberg. He works in the Multi-Asset Risk System (MARS) Pricing group in London, where he is focused on building scalable and reliable components for portfolio pricing and risk analysis. He is interested in the use of functional programming techniques for writing simpler and safer software. Prior to joining Bloomberg, he completed a master's degree at the University of Cambridge.