Book Image

Learning Functional Programming in Go

By : Lex Sheehan
Book Image

Learning Functional Programming in Go

By: Lex Sheehan

Overview of this book

Lex Sheehan begins slowly, using easy-to-understand illustrations and working Go code to teach core functional programming (FP) principles such as referential transparency, laziness, recursion, currying, and chaining continuations. This book is a tutorial for programmers looking to learn FP and apply it to write better code. Lex guides readers from basic techniques to advanced topics in a logical, concise, and clear progression. The book is divided into four modules. The first module explains the functional style of programming: pure functional programming, manipulating collections, and using higher-order functions. In the second module, you will learn design patterns that you can use to build FP-style applications. In the next module, you will learn FP techniques that you can use to improve your API signatures, increase performance, and build better cloud-native applications. The last module covers Category Theory, Functors, Monoids, Monads, Type classes and Generics. By the end of the book, you will be adept at building applications the FP way.
Table of Contents (21 chapters)
Title Page
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
Index

Chapter 8. Increasing Performance Using Pipelining

Often, we feel the need to work on some data and pass it along a series of steps, transforming it along the way before it arrives at its destination. We come across these sort of processes occurring in real-life scenarios, especially in factory assembly line environments.

In this chapter, we will see how the pipeline patterns can be used to build component-based applications. We'll see how we can use function composition data flow programming techniques to create flexible solutions that are not only robust, but also performant in today's distributed processing environments.

Our goal in this chapter is to do the following:

  • Be able to identify when to use the pipeline pattern
  • Learn how to build a pipeline
  • Understand how we can leverage buffering to increase throughput
  • Use Goroutines and channels to process data faster
  • Improve API readability using interfaces
  • Implement useful filters
  • Build a flexible pipeline
  • See what happens when you change the order...