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 Rust, you can develop robust and scalable applications that fulfill modern day software requirements. This book will help you discover all the Rust features that can be used to build software in a functional way.
We begin with a brief comparison of the functional and object-oriented approach to different problems and patterns. We then quickly look at the patterns of control flow, data the abstractions of these unique to Functional Programming. The next part covers how to create functional apps in Rust; mutability and ownership, which are exclusive to Rust, are also discussed. Pure functions are examined next and you'll master closures, their various types, and currying. We also look at implementing concurrency through functional design principles and metaprogramming using macros. Finally, we look at best practices for debugging and optimization.
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.
Author(s): Andrew Johnson
Publisher: Packt Publishing
Year: 2018
Language: English
Pages: 249
1: FUNCTIONAL PROGRAMMING – A COMPARISON
Technical requirements
Reducing code weight and complexity
Strict abstraction means safe abstraction
Improving project architecture
Summary
Questions
Further reading
2: FUNCTIONAL CONTROL FLOW
Technical requirements
Designing the program
Implementing program logic
Writing tests
Summary
Questions
3: FUNCTIONAL DATA STRUCTURES
Technical requirements
Adjusting to changing the scope of the project
Mapping requirements directly to code
Running simulations and analyzing data
Summary
Questions
4: GENERICS AND POLYMORPHISM
Technical requirements
Staying productive during downtime
Learning about generics
Applying parameterization concepts
Summary
Questions
5: CODE ORGANIZATION AND APPLICATION ARCHITECTURE
Technical requirements
Shipping a product without sacrificing quality
Reorganizing the project
Mapping code changes and additions
Summary
Questions
6: MUTABILITY, OWNERSHIP, AND PURE FUNCTIONS
Technical requirements
Recognizing anti-patterns of ownership
Learning the rules of ownership
Using immutable data
Using pure functions
Summary
Questions
7: DESIGN PATTERNS
Technical requirements
Using the functor pattern
Using the monad pattern
Using the combinator pattern
Using the lazy evaluation pattern
Summary
Questions
8: IMPLEMENTING CONCURRENCY
Technical requirements
Using subprocess concurrency
Understanding nix fork concurrency
Using thread concurrency
Understanding Send and Sync traits
Using functional design for concurrency
Summary
Questions
9: PERFORMANCE, DEBUGGING, AND METAPROGRAMMING
Technical requirements
Writing faster code
Preventing bugs with defensive coding
Finding and fixing bugs
Metaprogramming
Summary
Questions