▶Book Description
Functional programming is a programming paradigm for developing software using functions. Learning to use functional programming is a good way to write more concise code, with greater concurrency and performance. The JavaScript language is particularly suited to functional programming.
This book provides comprehensive coverage of the major topics in functional programming with JavaScript to produce shorter, clearer, and testable programs.
You'll delve into functional programming; including writing and testing pure functions, reducing side-effects, and other features to make your applications functional in nature.
Specifically, we'll explore techniques to simplify coding, apply recursion for loopless coding, learn ways to achieve immutability, implement design patterns, and work with data types.
By the end of this book, you'll have developed the JavaScript skills you need to program functional applications with confidence.
▶What You Will Learn
- Create more reliable code with closures and immutable data
- Convert existing methods into pure functions, and loops into recursive methods
- Develop more powerful applications with currying and function composition
- Separate the logic of your system from implementation details
- Implement composition and chaining techniques to simplify coding
- Use functional programming techniques where it makes the most sense
▶Key Features
- Become proficient and skilled with Functional Programming in JavaScript to solve real-world development problems
- Successfully apply Functional Programming concepts and techniques to everyday JavaScript programming
- Bring modularity, reusability, testability, and performance to your web apps
▶Who This Book Is For
If you are a JavaScript developer and want to apply functional programming techniques, then this book is for you. Only a basic knowledge of the concepts of functional programming is required for this book.
▶Style and approach
This book takes an easy-to-follow, step-by-step tutorial approach. You will make the most of JavaScript programming with a focus on the progression of functional programming techniques, styles, and detailed information about JavaScript libraries.
▶What this book covers
In this book, we'll cover Functional Programming (FP) in a practical way, though at times we will mention some theoretical points:
- Chapter 1, Becoming Functional - Several Questions, discusses FP, gives reasons for its usage, and lists the tools that you'll need to take advantage of the rest of the book.
- Chapter 2, Thinking Functionally - A First Example, will provide the first example of FP by considering a common web-related problem and going over several solutions, to finally center on a functional way.
- Chapter 3, Starting Out with Functions - A Core Concept, will go over the central concept of FP: functions, and the different options available in JavaScript.
- Chapter 4, Behaving Properly - Pure Functions, will consider the concept of purity and pure functions, and show how it leads to simpler coding and easier testing.
- Chapter 5, Programming Declaratively - A Better Style, will use simple data structures to show how to produce results working not in an imperative way, but in a declarative fashion.
- Chapter 6, Producing Functions - Higher-Order Functions, will deal with higher-order functions, which receive other functions as parameters and produce new functions as results.
- Chapter 7, Transforming Functions - Currying and Partial Application, will show some methods for producing new and specialized functions from earlier ones.
- Chapter 8, Connecting Functions - Pipelining and Composition, will show the key concepts regarding how to build new functions by joining previously defined ones.
- Chapter 9, Designing Functions - Recursion, will show how a key concept in FP, recursion, can be applied to designing algorithms and functions.
- Chapter 10, Ensuring Purity - Immutability, will show some tools that can help you work in a pure fashion by providing immutable objects and data structures.
- Chapter 11, Implementing Design Patterns - The Functional Way, will show how several popular OOP design patterns are implemented (or not needed!) when you program in FP ways.
- Chapter 12, Building Better Containers - Functional Data Types, will show some more highlevel functional patterns, introducing types, containers, functors, monads, and several other more advanced FP concepts.
I tried to keep examples simple and down-to-earth, because I wanted to focus on functional aspects and not on the intricacies of this or that problem. Some programming texts are geared toward learning, say, a given framework, and then work on a given problem, seeing how to fully work it out with the chosen tools. (Also, in fact, at the very beginning of planning for this book, I entertained the idea of developing an application that would use all the FP things I had in mind, but there was no way to fit all of that within a single project. Exaggerating a bit, I felt like an MD trying to find a patient on whom to apply all of his medical knowledge and treatments!) So, I opted to show plenty of individual techniques, which can be used in multiple situations. Rather than building a house, I want to show you how to put bricks together, how to wire things up, and so on, so that you will be able to apply whatever you need, as it may fit.