Friday, November 10, 2017

Learning Functional Programming in Go - Preface

Until recently the message has been, "Go and Functional Programming.  Don't it."

Functional Programming (FP) is a perfect fit for multi-core, parallel processing.  Go is a concurrency baller (with Goroutines, channels, etc.) and already runs on every available CPU core.

FP reduces complexity.  Simplicity is one on Go’s biggest strengths.

FP scales.  Go scales and we already covered this.  Go away.

So, what can FP bring to Go that will actually improve our software applications?
  • Composition.  FP shows us how to decompose our apps and rebuild them by reusing small building blocks.
  • Monads. Using monads, we are able to safely order our workflows into pipelines of data transformations.
  • Error handling. We can leverage monadic error handling and still maintain compatibility with idiomatic Go code.
  • Performance.  Referential transparency is where we can evaluate our function once and subsequently refer to its pre-computed value.
  • Expressive code.  FP allows us to concisely express business intent in our code. We declare what our functions do, without the clutter of error checking after every function call and without having to follow state changes (pure FP means immutable variables).
  • Simpler code. No shared data means not having to deal with semaphores, locks, race conditions  or deadlocks.
Most people have difficulty grasping functional programming.

I did, too.  When I “got it” I wrote this book.  Take this journey with me.  You’ll see hundreds of illustrations, read easy-to-understand explanations and implement FP in Go code along the way.

I enjoyed coaching soccer. The litmus test I used to determine whether I succeeded as a coach was the answer to this simple question, "Did they all register for next season and request for me to be their coach?"  Just like planning practice, I planned each chapter; Starting with simple concepts and adding to them.  Read this book.  Then you, too, will be able to say, “I got it.”

If you want to improve your FP skills this book is for you.


Coach Lex

2 comments: