My Account Log in

3 options

Learning C++ functional programming : metaprogramming, concurrency, lazy evaluation, and more / Wisnu Anggoro.

EBSCOhost Academic eBook Collection (North America) Available online

View online

Ebook Central College Complete Available online

View online

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Anggoro, Wisnu, author.
Language:
English
Subjects (All):
Functional programming (Computer science).
C++ (Computer program language).
Physical Description:
1 online resource (286 pages) : illustrations
Edition:
1st edition
Other Title:
Learning C plus plus functional programming
Place of Publication:
Birmingham, England ; Mumbai, [India] : Packt, 2017.
System Details:
Mode of access: World Wide Web.
text file
Biography/History:
Anggoro Wisnu: Wisnu Anggoro is a Microsoft Certified Professional in C# programming and an experienced C/C++ developer. He has also authored the books Boost. Asio C++ Network Programming - Second Edition and Functional C# by Packt. He has been programming since he was in junior high school, which was about 20 years ago, and started developing computer applications using the BASIC programming language in the MS-DOS environment. He has solid experience in smart card programming, as well as desktop and web application programming, including designing, developing, and supporting the use of applications for SIM Card Operating System Porting, personalization, PC/SC communication, and other smart card applications that require the use of C# and C/C++. He is currently a senior smart card software engineer at CIPTA, an Indonesian company that specializes in innovation and technology for smart cards. He can be reached through his email at wisnu@anggoro. net
Summary:
Apply Functional Programming techniques to C++ to build highly modular, testable, and reusable code About This Book Modularize your applications and make them highly reusable and testable Get familiar with complex concepts such as metaprogramming, concurrency, and immutability A highly practical guide to building functional code in C++ filled with lots of examples and real-world use cases Who This Book Is For This book is for C++ developers comfortable with OOP who are interested in learning how to apply the functional paradigm to create robust and testable apps. 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 In Detail 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. 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. Style and approach This book uses a module-based approach, where each module will cover important aspects of functional programming in C++ and will help you develop efficient and robust applications through gaining a practical understanding.
Contents:
Cover
Copyright
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Table of Contents
Preface
Chapter 1: Diving into Modern C++
Getting closer with several new features in modern C++
Defining the data type automatically using the auto keyword
Querying the type of an expression using the decltype keyword
Pointing to a null pointer
Returning an iterator using non-member begin() and end() function
Iterating over collections using range-based for loops
Leveraging the use of C++ language with the C++ Standard Libraries
Placing any objects in the container
Using algorithms
Simplifying the function notation using a Lambda expression
Using the Lambda expression for a tiny function
Using the Lambda expression for multiline functions
Returning a value from the Lambda expression
Capturing a value to the Lambda expression
Preparing the value using initialization captures
Writing a generic Lambda expression to be used many times with many different data types
Avoiding manual memory management with smart pointers
Replacing a raw pointer using unique_ptr
Sharing objects using shared_ptr
Tracking the objects using a weak_ptr pointer
Storing many different data types using tuples
Unpacking tuples values
Returning a tuple value type
Summary
Chapter 2: Manipulating Functions in Functional Programming
Applying the first-class function in all functions
Passing a function as another function's parameter
Assigning a function to a variable
Storing a function in the container
Creating a new function from the existing functions at runtime
Getting acquainted with three functional techniques in the higher-order function
Executing each element list using map
Extracting data using filter.
Combining all elements of a list using fold
Avoiding the side effect with pure function
Reducing a multiple arguments function with currying
Chapter 3: Applying Immutable State to the Function
Understanding the essential part from immutable object
Modifying a local variable
Modifying a variable passed into a function
Preventing the modification of a value
Applying the first-class function and the pure function to the immutable object
Developing the immutable object
Starting with a mutable object
Refactoring a mutable object into an immutable one
Enumerating the benefits of being immutable
Chapter 4: Repeating Method Invocation Using Recursive Algorithm
Repeating the function invocation recursively
Performing the iteration procedure to repeat the process
Performing the recursion procedure to repeat the process
Recurring the immutable function
Getting closer to tail recursion
Getting acquainted with functional, procedural, and backtracking recursion
Expecting results from functional recursion
Running a task recursively in procedural recursion
Backtracking recursion
Chapter 5: Procrastinating the Execution Process Using Lazy Evaluation
Evaluating the expression
Running the expression immediately with strict evaluation
Delaying the expression with non-strict evaluation
The basic concept of lazy evaluation
Delaying the process
Caching the value using the memoization technique
Optimizing the code using the memoization technique
Lazy evaluation in action
Designing Chunk and Row classes
Concatenating several rows
Iterating each Row class' element
Generating the infinite integer row
Generating an infinite prime numbers row
Refactoring eager evaluation to lazy evaluation
Summary.
Chapter 6: Optimizing Code with Metaprogramming
Introduction to metaprogramming
Preprocessing the code using a macro
Dissecting template metaprogramming in the Standard Library
Building the template metaprogramming
Adding a value to the variable in the template
Mapping a function to the input parameters
Choosing the correct process based on the condition
Repeating the process recursively
Selecting a type in compile-time
Flow control with template metaprogramming
Deciding the next process by the current condition
Selecting the correct statement
Looping the process
Executing the code in compile-time
Getting a compile-time constant
Generating the class using a compile-time class generation
Benefits and drawbacks of metaprogramming
Chapter 7: Running Parallel Execution Using Concurrency
Concurrency in C++
Processing a single threading code
Processing a multithreading code
Synchronizing the threads using mutex
Avoiding synchronization issues
Unlocking the variable automatically
Avoiding deadlock using recursive mutex
Understanding the thread processing in a Windows operating system
Working with handle
Refactoring to a unique handle
Triggering an event
Calling an event from a thread
Chapter 8: Creating and Debugging Application in Functional Approach
Preparing an imperative class
Refactoring the imperative class to become a functional class
Passing a function as a parameter
Adding a base class
Transforming the class to become pure
Filtering the condition and implementing a Lambda expression
Implementing recursion and memoization techniques to the Customer class
Debugging the code
Starting the debugging tool
Continuing and stepping the debugging process
Setting and deleting the breakpoint.
Printing the object value
Index.
Notes:
Includes index.
Includes bibliographical references and index.
Description based on online resource; title from PDF title page (ebrary, viewed September 11, 2017).
OCLC:
1003042450

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

Find

Home Release notes

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Find catalog Using Articles+ Using your account