【文件属性】:
文件名称:Learning Functional Programming in Go-Packt Publishing(2017).pdf
文件大小:32.64MB
文件格式:PDF
更新时间:2021-03-28 15:32:42
Functional Programming Go
Until recently, the message has been Go and functional programming—don't do it.
Functional programming (FP) is a perfect fit for multicore, parallel processing. Go is a
concurrency baller (with Goroutines, channels, and so on) and already runs on every
available CPU core. FP reduces complexity; simplicity is one of Go's biggest strengths.
So, what can FP bring to Go that will actually improve our software applications? Here's
what it offers:
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 then 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 FP.
I did too. And when I got it, I wrote this book. Take this journey with me. We'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
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.