Book description
Leverage Modern Language Constructs to Write High-Quality Code Faster
The functional and concurrent programming language features supported by modern languages can be challenging, even for experienced developers. These features may appear intimidating to OOP programmers because of a misunderstanding of how they work. Programmers first need to become familiar with the abstract concepts that underlie these powerful features.
In Functional and Concurrent Programming, Michel Charpentier introduces a core set of programming language constructs that will help you be productive in a variety of programming languagesnow and in the future. Charpentier illustrates key concepts with numerous small, focused code examples, written in Scala, and with case studies that provide a thorough grounding in functional and concurrent programming skills. These skills will carry from language to languageincluding the most recent incarnations of Java. Using these features will enable developers and programmers to write high-quality code that is easier to understand, debug, optimize, and evolve.
Key topics covered include:
Recursion and tail recursion
Pattern matching and algebraic datatypes
Persistent structures and immutability
Higher-order functions and lambda expressions
Lazy evaluation and streams
Threads and thread pools
Atomicity and locking
Synchronization and thread-safe objects
Lock-free, non-blocking patterns
Futures, promises, and functional-concurrent programming
As a bonus, the book includes a discussion of common typing strategies used in modern programming languages, including type inference, subtyping, polymorphism, type classes, type bounds, and type variance.
Most of the code examples are in Scala, which includes many of the standard features of functional and concurrent programming; however, no prior knowledge of Scala is assumed. You should be familiar with concepts such as classes, methods, objects, types, variables, loops, and conditionals and have enough programming experience to not be distracted by simple matters of syntax.
Table of contents
- Cover Page
- About This eBook
- Halftitle Page
- Title Page
- Copyright Page
- Dedication Page
- Contents
- List of Listings
- List of Figures
- Foreword by Cay Horstmann
- Preface
- Acknowledgments
- About the Author
-
Part I: Functional Programming
- Chapter 1. Concepts of Functional Programming
- Chapter 2. Functions in Programming Languages
- Chapter 3. Immutability
- Chapter 4. Case Study: Active–Passive Sets
- Chapter 5. Pattern Matching and Algebraic Data Types
- Chapter 6. Recursive Programming
-
Chapter 7. Recursion on Lists
- 7.1 Recursive Algorithms as Equalities
- 7.2 Traversing Lists
- 7.3 Returning Lists
- 7.4 Building Lists from the Execution Stack
- 7.5 Recursion on Multiple/Nested Lists
- 7.6 Recursion on Sublists Other Than the Tail
- 7.7 Building Lists in Reverse Order
- 7.8 Illustration: Sorting
- 7.9 Building Lists Efficiently
- 7.10 Summary
- Chapter 8. Case Study: Binary Search Trees
- Chapter 9. Higher-Order Functions
-
Chapter 10. Standard Higher-Order Functions
- 10.1 Functions with Predicate Arguments
- 10.2 map and foreach
- 10.3 flatMap
- 10.4 fold and reduce
- 10.5 iterate, tabulate, and unfold
- 10.6 sortWith, sortBy, maxBy, and minBy
- 10.7 groupBy and groupMap
- 10.8 Implementing Standard Higher-Order Functions
- 10.9 foreach, map, flatMap, and for-Comprehensions
- 10.10 Summary
- Chapter 11. Case Study: File Systems as Trees
-
Chapter 12. Lazy Evaluation
- 12.1 Delayed Evaluation of Arguments
- 12.2 By-Name Arguments
- 12.3 Control Abstraction
- 12.4 Internal Domain-Specific Languages
- 12.5 Streams as Lazily Evaluated Lists
- 12.6 Streams as Pipelines
- 12.7 Streams as Infinite Data Structures
- 12.8 Iterators
- 12.9 Lists, Streams, Iterators, and Views
- 12.10 Delayed Evaluation of Fields and Local Variables
- 12.11 Illustration: Subset-Sum
- 12.12 Summary
- Chapter 13. Handling Failures
- Chapter 14. Case Study: Trampolines
- A Brief Interlude
-
Part II: Concurrent Programming
- Chapter 16. Concepts of Concurrent Programming
- Chapter 17. Threads and Nondeterminism
- Chapter 18. Atomicity and Locking
- Chapter 19. Thread-Safe Objects
- Chapter 20. Case Study: Thread-Safe Queue
- Chapter 21. Thread Pools
- Chapter 22. Synchronization
- Chapter 23. Common Synchronizers
-
Chapter 24. Case Study: Parallel Execution
- 24.1 Sequential Reference Implementation
- 24.2 One New Thread per Task
- 24.3 Bounded Number of Threads
- 24.4 Dedicated Thread Pool
- 24.5 Shared Thread Pool
- 24.6 Bounded Thread Pool
- 24.7 Parallel Collections
- 24.8 Asynchronous Task Submission Using Conditions
- 24.9 Two-Semaphore Implementation
- 24.10 Summary
- Chapter 25. Futures and Promises
- Chapter 26. Functional-Concurrent Programming
- Chapter 27. Minimizing Thread Blocking
-
Chapter 28. Case Study: Parallel Strategies
- 28.1 Problem Definition
- 28.2 Sequential Implementation with Timeout
- 28.3 Parallel Implementation Using invokeAny
- 28.4 Parallel Implementation Using CompletionService
- 28.5 Asynchronous Implementation with Scala Futures
- 28.6 Asynchronous Implementation with CompletableFuture
- 28.7 Caching Results from Strategies
- 28.8 Summary
-
Appendix A. Features of Java and Kotlin
- A.1 Functions in Java and Kotlin
- A.2 Immutability
- A.3 Pattern Matching and Algebraic Data Types
- A.4 Recursive Programming
- A.5 Higher-Order Functions
- A.6 Lazy Evaluation
- A.7 Handling Failures
- A.8 Types
- A.9 Threads
- A.10 Atomicity and Locking
- A.11 Thread-Safe Objects
- A.12 Thread Pools
- A.13 Synchronization
- A.14 Futures and Functional-Concurrent Programming
- A.15 Minimizing Thread Blocking
- Glossary
- Index
Product information
- Title: Functional and Concurrent Programming: Core Concepts and Features
- Author(s):
- Release date: December 2022
- Publisher(s): Addison-Wesley Professional
- ISBN: 9780137466696
You might also like
video
Ultimate Go Programming, Second Edition
An updated edition of this video title is available. Please go to Ultimate Go: Advanced Concepts …
book
Command-Line Rust
Updated in 2024: A new version has been released that simplifies the programs used in the …
book
A Functional Approach to Java
Java developers usually tackle the complexity of software development through object-oriented programming (OOP). But not every …
book
Functional Design: Principles, Patterns, and Practices
A Practical Guide to Better, Cleaner Code with Functional Programming In Functional Design, renowned software engineer …