November 2017
Intermediate to advanced
670 pages
17h 35m
English
In Chapter 1, Pure Functional Programming in Go, we briefly discussed immutable variables, but did not dive much into why they are so bad. Let's do that now that we have a concrete example in mind.
Functional impurity
Also covered in Chapter 1, Pure Functional Programming in Go, pure functions always return the same result, given the same inputs and never have side effects. Global variables cause any function that references it to be impure.
Code complexity and bugs
Global variables by definition are available to a number of functions. It quickly becomes difficult to understand the cause and effect aspects of program flow when a function behaves differently based on its value and other functions are changing that ...