3 Functional data structures and immutability
This chapter covers
- Building parallel applications with functional data structures
- Using immutability for high-performant, lock-free code
- Implementing parallel patterns with functional recursion
- Implementing immutable objects in C# and F#
- Working with tree data structures
Data comes in a multitude of forms. Consequently, it’s not surprising that many computer programs are organized around two primary constraints: data and data manipulation. Functional programming fits well into this world because, to a large extent, this programming paradigm is about data transformation. Functional transformations allow you to alter a set of structured data from its original form into another form without having to worry about side effects or state. For example, you can transform a collection of countries into a collection of cities using a map function and keep the initial data unchanged. Side effects are a key challenge for concurrent programming because the effects raised in one thread can influence the behavior of another thread.