Learning C++ Functional Programming

Apply Functional Programming techniques to C++ to build highly modular, testable, and reusable code

Learning C++ Functional Programming

This ebook is included in a Mapt subscription
Wisnu Anggoro

Apply Functional Programming techniques to C++ to build highly modular, testable, and reusable code
$0.00
$20.00
$49.99
$29.99p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781787281974
Paperback304 pages

Book Description

Functional programming allows developers to divide programs into smaller, reusable components that ease the creation, testing, and maintenance of software as a whole. Combined with the power of C++, you can develop robust and scalable applications that fulfill modern day software requirements. This book will help you discover all the C++ 17 features that can be applied to build software in a functional way.The book is divided into three modules—the first introduces the fundamentals of functional programming and how it is supported by modern C++. The second module explains how to efficiently implement C++ features such as pure functions and immutable states to build robust applications. The last module describes how to achieve concurrency and apply design patterns to enhance your application’s performance. Here, you will also learn to optimize code using metaprogramming in a functional way.

The book is divided into three modules—the first introduces the fundamentals of functional programming and how it is supported by modern C++. The second module explains how to efficiently implement C++ features such as pure functions and immutable states to build robust applications. The last module describes how to achieve concurrency and apply design patterns to enhance your application’s performance. Here, you will also learn to optimize code using metaprogramming in a functional way. The book is divided into three modules—the first introduces the fundamentals of functional programming and how it is supported by modern C++. The second module explains how to efficiently implement C++ features such as pure functions and immutable states to build robust applications. The last module describes how to achieve concurrency and apply design patterns to enhance your application’s performance. Here, you will also learn to optimize code using metaprogramming in a functional way.

By the end of the book, you will be familiar with the functional approach of programming and will be able to use these techniques on a daily basis.

Table of Contents

Chapter 1: Diving into Modern C++
Getting closer with several new features in modern C++
Leveraging the use of C++ language with the C++ Standard Libraries
Simplifying the function notation using a Lambda expression
Avoiding manual memory management with smart pointers
Storing many different data types using tuples
Summary
Chapter 2: Manipulating Functions in Functional Programming
Applying the first-class function in all functions
Getting acquainted with three functional techniques in the higher-order function
Avoiding the side effect with pure function
Reducing a multiple arguments function with currying
Summary
Chapter 3: Applying Immutable State to the Function
Understanding the essential part from immutable object
Preventing the modification of a value
Applying the first-class function and the pure function to the immutable object
Developing the immutable object
Enumerating the benefits of being immutable
Summary
Chapter 4: Repeating Method Invocation Using Recursive Algorithm
Repeating the function invocation recursively
Recurring the immutable function
Getting closer to tail recursion
Getting acquainted with functional, procedural, and backtracking recursion
Summary
Chapter 5: Procrastinating the Execution Process Using Lazy Evaluation
Evaluating the expression
The basic concept of lazy evaluation
Lazy evaluation in action
Summary
Chapter 6: Optimizing Code with Metaprogramming
Introduction to metaprogramming
Building the template metaprogramming
Selecting a type in compile-time
Flow control with template metaprogramming
Executing the code in compile-time
Benefits and drawbacks of metaprogramming
Summary
Chapter 7: Running Parallel Execution Using Concurrency
Concurrency in C++
Synchronizing the threads using mutex
Understanding the thread processing in a Windows operating system
Summary
Chapter 8: Creating and Debugging Application in Functional Approach
Preparing an imperative class
Refactoring the imperative class to become a functional class
Debugging the code
Summary

What You Will Learn

  • Get to know the difference between imperative and functional approaches
  • See the use of first-class functions and pure functions in a functional style
  • Discover various techniques to apply immutable state to avoid side effects
  • Design a recursive algorithm effectively
  • Create faster programs using lazy evaluation
  • Structure code using design patterns to make the design process easier
  • Use concurrency techniques to develop responsive software
  • Learn how to use the C++ Standard Template Library and metaprogramming in a functional way to improve code optimization

Authors

Table of Contents

Chapter 1: Diving into Modern C++
Getting closer with several new features in modern C++
Leveraging the use of C++ language with the C++ Standard Libraries
Simplifying the function notation using a Lambda expression
Avoiding manual memory management with smart pointers
Storing many different data types using tuples
Summary
Chapter 2: Manipulating Functions in Functional Programming
Applying the first-class function in all functions
Getting acquainted with three functional techniques in the higher-order function
Avoiding the side effect with pure function
Reducing a multiple arguments function with currying
Summary
Chapter 3: Applying Immutable State to the Function
Understanding the essential part from immutable object
Preventing the modification of a value
Applying the first-class function and the pure function to the immutable object
Developing the immutable object
Enumerating the benefits of being immutable
Summary
Chapter 4: Repeating Method Invocation Using Recursive Algorithm
Repeating the function invocation recursively
Recurring the immutable function
Getting closer to tail recursion
Getting acquainted with functional, procedural, and backtracking recursion
Summary
Chapter 5: Procrastinating the Execution Process Using Lazy Evaluation
Evaluating the expression
The basic concept of lazy evaluation
Lazy evaluation in action
Summary
Chapter 6: Optimizing Code with Metaprogramming
Introduction to metaprogramming
Building the template metaprogramming
Selecting a type in compile-time
Flow control with template metaprogramming
Executing the code in compile-time
Benefits and drawbacks of metaprogramming
Summary
Chapter 7: Running Parallel Execution Using Concurrency
Concurrency in C++
Synchronizing the threads using mutex
Understanding the thread processing in a Windows operating system
Summary
Chapter 8: Creating and Debugging Application in Functional Approach
Preparing an imperative class
Refactoring the imperative class to become a functional class
Debugging the code
Summary

Book Details

ISBN 139781787281974
Paperback304 pages
Read More

Read More Reviews