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

Managing Complexity


As systems engineers, we must build and integrate elements and subsystems to achieve a desired objective. There can be a lot of moving parts: various APIs and communication protocols, various data schemas, various security interfaces to traverse. Our biggest challenge is, How do we manage all this complexity?

The best tool for the job

The best tool we have  to help manage complexity is composition. Functional programming to the rescue!

Our job is to decompose the elements of our system into atomic parts, fit them back together into subsystems and wire them together in a distributed, microservice based environment.

How do we know when have we sufficiently decomposed an element?

A: When we can treat the element as a black box, i.e., when we do not need visibility into the function to understand what it does.

Divide and conquer

FP gives us the tools and techniques we need to divide our monolithic applications into microservices.

In Chapter 4SOLID Design in Go, we learned that...