Functional Programming in C++: A Modern Approach
Functional Programming in C++: A Modern Approach
Summary:
The book "Functional Programming in C++" is a practical guide for developers who want to go beyond the imperative style and master the functional programming (FP) paradigm in the context of modern C++. The author, Alexey Vetrov, a senior developer with many years of experience, systematically reveals FP concepts, adapting them to the capabilities of C++17 and C++20.
Who is this book for?
- Practicing C++ developers who want to write more predictable and easily testable code.
- Programmers familiar with the basics of C++ but striving to master functional approaches (lambdas, monads, algebraic data types).
- Students and teachers studying modern programming methodologies.
What will you learn from the book?
- FP Basics in C++: pure functions, immutability, absence of side effects, working with immutable data structures.
- Lambda Expressions and Function Objects: how to effectively use closures, variable capture, and passing functions as arguments.
- Function Composition and Currying: building complex logic from simple building blocks using std::function and templates.
- Monads and Functors: implementing Maybe (std::optional), Either, and IO monads in C++ for safe error handling and pure input/output.
- Algebraic Data Types: the visitor pattern, std::variant, recursive types, and pattern matching.
- FP Patterns: memoization, lazy evaluation, monadic chains, and stream data processing (ranges).
- Integration with STL: using std::transform, std::accumulate, std::optional, and std::expected in a functional style.
Why should you read this book?
Functional programming makes code more declarative, reduces bugs related to state, and simplifies parallel execution. The book contains many examples, from simple (sorting via lambdas) to advanced (building a parser on monads). All examples have been tested on GCC and Clang compilers with C++17/20 flags.
About the author: Alexey Vetrov is an author of technical articles on C++ and functional programming, and a participant in C++ Russia and Meeting C++ conferences. In the book, he shares real-world experience of implementing FP in commercial projects.
The book will be useful for anyone who wants to raise their level of C++ proficiency and learn to write elegant, safe, and easily maintainable code.
Recommendations
Professional Swift (iOS/macOS): Advanced Techniques
Refactoring Swift (iOS/macOS) Code
Go (Golang) for Data Science: A Practical Guide
Java and Kubernetes: Microservice Development and Deployment
Refactoring PHP Code: Improving and Maintaining Code
RxJS in Action. Reactive Programming with TypeScript