Functional Programming in JavaScript: How to improve your JavaScript programs using functional techniques
Summary

Functional Programming in JavaScript teaches JavaScript developers functional techniques that will improve extensibility, modularity, reusability, testability, and performance. Through concrete examples and jargon-free explanations, this book teaches you how to apply functional programming to real-life development tasks

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

In complex web applications, the low-level details of your JavaScript code can obscure the workings of the system as a whole. As a coding style, functional programming (FP) promotes loosely coupled relationships among the components of your application, making the big picture easier to design, communicate, and maintain.

About the Book

Functional Programming in JavaScript teaches you techniques to improve your web applications - their extensibility, modularity, reusability, and testability, as well as their performance. This easy-to-read book uses concrete examples and clear explanations to show you how to use functional programming in real life. If you're new to functional programming, you'll appreciate this guide's many insightful comparisons to imperative or object-oriented programming that help you understand functional design. By the end, you'll think about application design in a fresh new way, and you may even grow to appreciate monads!

What's Inside
  • High-value FP techniques for real-world uses
  • Using FP where it makes the most sense
  • Separating the logic of your system from implementation details
  • FP-style error handling, testing, and debugging
  • All code samples use JavaScript ES6 (ES 2015)

About the Reader
Written for developers with a solid grasp of JavaScript fundamentals and web application design.
About the Author
Luis Atencio is a software engineer and architect building enterprise applications in Java, PHP, and JavaScript.
Table of Contents
    PART 1 THINK FUNCTIONALLY
  1. Becoming functional
  2. Higher-order JavaScript
  3. PART 2 GET FUNCTIONAL
  4. Few data structures, many operations
  5. Toward modular, reusable code
  6. Design patterns against complexity
  7. PART 3 ENHANCING YOUR FUNCTIONAL SKILLS
  8. Bulletproofing your code
  9. Functional optimizations
  10. Managing asynchronous events and data
1123921923
Functional Programming in JavaScript: How to improve your JavaScript programs using functional techniques
Summary

Functional Programming in JavaScript teaches JavaScript developers functional techniques that will improve extensibility, modularity, reusability, testability, and performance. Through concrete examples and jargon-free explanations, this book teaches you how to apply functional programming to real-life development tasks

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

In complex web applications, the low-level details of your JavaScript code can obscure the workings of the system as a whole. As a coding style, functional programming (FP) promotes loosely coupled relationships among the components of your application, making the big picture easier to design, communicate, and maintain.

About the Book

Functional Programming in JavaScript teaches you techniques to improve your web applications - their extensibility, modularity, reusability, and testability, as well as their performance. This easy-to-read book uses concrete examples and clear explanations to show you how to use functional programming in real life. If you're new to functional programming, you'll appreciate this guide's many insightful comparisons to imperative or object-oriented programming that help you understand functional design. By the end, you'll think about application design in a fresh new way, and you may even grow to appreciate monads!

What's Inside
  • High-value FP techniques for real-world uses
  • Using FP where it makes the most sense
  • Separating the logic of your system from implementation details
  • FP-style error handling, testing, and debugging
  • All code samples use JavaScript ES6 (ES 2015)

About the Reader
Written for developers with a solid grasp of JavaScript fundamentals and web application design.
About the Author
Luis Atencio is a software engineer and architect building enterprise applications in Java, PHP, and JavaScript.
Table of Contents
    PART 1 THINK FUNCTIONALLY
  1. Becoming functional
  2. Higher-order JavaScript
  3. PART 2 GET FUNCTIONAL
  4. Few data structures, many operations
  5. Toward modular, reusable code
  6. Design patterns against complexity
  7. PART 3 ENHANCING YOUR FUNCTIONAL SKILLS
  8. Bulletproofing your code
  9. Functional optimizations
  10. Managing asynchronous events and data
34.99 In Stock
Functional Programming in JavaScript: How to improve your JavaScript programs using functional techniques

Functional Programming in JavaScript: How to improve your JavaScript programs using functional techniques

by Luis Atencio
Functional Programming in JavaScript: How to improve your JavaScript programs using functional techniques

Functional Programming in JavaScript: How to improve your JavaScript programs using functional techniques

by Luis Atencio

eBook

$34.99 

Available on Compatible NOOK devices, the free NOOK App and in My Digital Library.
WANT A NOOK?  Explore Now

Related collections and offers


Overview

Summary

Functional Programming in JavaScript teaches JavaScript developers functional techniques that will improve extensibility, modularity, reusability, testability, and performance. Through concrete examples and jargon-free explanations, this book teaches you how to apply functional programming to real-life development tasks

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

In complex web applications, the low-level details of your JavaScript code can obscure the workings of the system as a whole. As a coding style, functional programming (FP) promotes loosely coupled relationships among the components of your application, making the big picture easier to design, communicate, and maintain.

About the Book

Functional Programming in JavaScript teaches you techniques to improve your web applications - their extensibility, modularity, reusability, and testability, as well as their performance. This easy-to-read book uses concrete examples and clear explanations to show you how to use functional programming in real life. If you're new to functional programming, you'll appreciate this guide's many insightful comparisons to imperative or object-oriented programming that help you understand functional design. By the end, you'll think about application design in a fresh new way, and you may even grow to appreciate monads!

What's Inside
  • High-value FP techniques for real-world uses
  • Using FP where it makes the most sense
  • Separating the logic of your system from implementation details
  • FP-style error handling, testing, and debugging
  • All code samples use JavaScript ES6 (ES 2015)

About the Reader
Written for developers with a solid grasp of JavaScript fundamentals and web application design.
About the Author
Luis Atencio is a software engineer and architect building enterprise applications in Java, PHP, and JavaScript.
Table of Contents
    PART 1 THINK FUNCTIONALLY
  1. Becoming functional
  2. Higher-order JavaScript
  3. PART 2 GET FUNCTIONAL
  4. Few data structures, many operations
  5. Toward modular, reusable code
  6. Design patterns against complexity
  7. PART 3 ENHANCING YOUR FUNCTIONAL SKILLS
  8. Bulletproofing your code
  9. Functional optimizations
  10. Managing asynchronous events and data

Product Details

ISBN-13: 9781638353591
Publisher: Manning
Publication date: 06/06/2016
Sold by: SIMON & SCHUSTER
Format: eBook
Pages: 272
File size: 7 MB

About the Author

Luis Atencio is a software engineer for Citrix Systems, author of Manning’s Functional Programming in JavaScript, and co-author of Manning’s RxJS in Action.

Table of Contents

Preface xv

Acknowledgments xvii

About this book xix

Part 1 Think Functionally 1

1 Becoming functional 3

1.1 Can functional programming help? 5

1.2 What is functional programming? 5

Functional programming is declarative 7

Pure functions and the problem with side effects 9

Referential transparency and substitutability 13

Preserving immutable data 15

1.3 Benefits of functional programming 16

Encouraging the decomposition of complex tasks 16

Processing data using fluent chains 18

Reacting to the complexity of asynchronous applications 19

1.4 Summary 22

2 Higher-order JavaScript 23

2.1 Why JavaScript? 24

2.2 Functional vs. object-oriented programming 24

Managing the state of JavaScript objects 31

Treating objects as valves 32

Deep-freezing moving parts 34

Navigating and modifying object graphs with lenses 37

2.3 Functions 38

Functions as first-class citizens 39

Higher-order functions 40 Types of function invocation 43

Function methods 44

2.4 Closures and scopes 45

Problems with the global scope 47

JavaScripts function scope 48

A pseudo-block scope 49

Practical applications of closures 50

2.5 Summary 53

Part 2 Get Functional 55

3 Few data structures, many operations 57

3.1 Understanding your application's control flow 58

3.2 Method chaining 59

3.3 Function chaining 60

Understanding lambda expressions 61

Transforming data with - map 62

Gathering results with -reduce 65

Removing unwanted elements with -filter 68

3.4 Reasoning about your code 70

Declarative and lazy function chains 71

SQL-like data: functions as data 75

3.5 Learning to think recursively 77

What is recursion? 77

Learning to think recursively 77

Recursively defined data structures 79

3.6 Summary 83

4 Toward modular, reusable code 84

4.1 Method chains vs. function pipelines 85

Chaining methods together 86

Arranging functions in a pipeline 87

4.2 Requirements for compatible functions 88

Type-compatible functions 88

Functions and arity: the case for tuples 89

4.3 Curried function evaluation 92

Emulating function factories 95

Implementing reusable function templates 97

4.4 Partial application and parameter binding 98

Extending the am language 100

Binding into delayed functions 101

4.5 Composing function pipelines 102

Understanding composition with HTML widgets 102

Functional composition: separating description from evaluation 104

Composition with functional libraries 107

Coping with pure and impure code 109

Introducing point-free programming 111

4.6 Managing control flow with functional combinators 112

Identity (I-combinator) 112

Tap (K-combinator) 113

Alternation (OR-combinator) 113

Sequence (S-combinator) 114

Fork (join) combinator 115

4.7 Summary 116

5 Design patterns against complexity 117

5.1 Shortfalls of imperative error handling 118

Error handling with try-catch 118

Reasons not to throw exceptions in functional programs 119

Problems with null-checking 121

5.2 Building a better solution: functors 121

Wrapping unsafe values 122

Functors explained 124

5.3 Functional error handling using monads 127

Monads: from control flow to dataflow 128

Error handling with Maybe and Either monads 132

Interacting with external resources using the IO monad 141

5.4 Monadic chains and compositions 144

5.5 Summary 150

Part 3 Enhancing Your Functional Skills 151

6 Bulletproofing your code 153

6.1 Functional programming's influence on unit tests 154

6.2 Challenges of testing imperative programs 155

Difficulty identifying and decomposing tasks 155

Dependency on shared resources leads to inconsistent results 157

Predefined order of execution 158

6.3 Testing functional code 159

Treating a function as a black box 159

Focusing on business logic instead of control flow 160

Separating the pure from the impure with monadic isolation 161

Mocking external dependencies 164

6.4 Capturing specifications with property-based testing 166

6.5 Measuring effectiveness through code coverage 172

Measuring the effectiveness of testing functional code 173

Measuring the complexity of functional code 177

6.6 Summary 179

7 Functional optimizations 180

7.3 Under the hood of function execution 181

Currying and the function context stack 183

Challenges of recursive code 186

7.2 Deferring execution using lazy evaluation 188

Avoiding computations with the alternation functional combinator 189

Taking advantage of shortcut fusion 190

7.3 Implementing a call-when-needed strategy 191

Understanding memoization 192

Memoizing computationally intensive functions 192

Taking advantage of currying and memoization 196

Decomposing to maximize memoization 196

Applying memoization to recursive calls 197

7.4 Recursion and tail-call optimization (TCO) 199

Converting non-tail calls to tail calls 201

7.5 Summary 203

8 Managing asynchronous events and data 205

8.1 Challenges of asynchronous code 206

Creating temporal dependencies among functions 207

Falling into a callback pyramid 208

Using continuation-passing style 210

8.2 First-class asynchronous behavior with promises 214

Future method chains 216

Composing synchronous and asynchronous behavior 221

8.3 Lazy data generation 224

Generators and recursion 226

The Iterator protocol 228

8.4 Functional and reactive programming with RxJS 229

Data as observable sequences 229

Functional and reactive programming 230

RxJS and promises 233

8.5 Summary 234

Appendix JavaScript libraries used in this book 235

Index 239

From the B&N Reads Blog

Customer Reviews