23 July 2019
Over recent years, functional programming features have crept into many procedural and object-oriented languages, including C++. In functional programming, data structures and user-defined types are typically immutable, and their state is typically transformed through a series of pure functions rather than being mutated in place. This is often avoided in object-oriented languages as it is seen as less efficient. However, the cost is typically not as severe as it might seem, because of a property of immutable data types known as structural sharing. In addition, there are many cases where it's beneficial, especially in a concurrent application, where it can remove the need for locks. In fact, lack of familiarity and cumbersome syntax are typically the greater impediments to adoption.
In this talk, we'll look at an implementation of immutable records based on the immutable maps available in the C++ immer library. We will also look at a technique from functional programming which makes it more convenient to manipulate deeply nested immutable records: namely, lenses. The implementation of the record type is also pseudo-dynamic, in the sense that code can be agnostic to the presence of additional fields in the record, provided that the required fields are present.
7.00pm: Arrive for networking and chat, with pizza & beverages courtesy of DisplayLink
7.30pm: Anton will deliver his talk. There will be time for Q&A.
~9.00pm: Close, with option to continue conversation at the pub