- Learning Functional Programming in Go
- Lex Sheehan
- 132字
- 2025-02-27 05:14:35
Reality check
What? A for loop? A mutating car variable? What gives? We must face the facts. The Go compiler does not provide TCO, so a recursive implementation is simply not practical. Perhaps Go 2.0 will provide a pure functional library with all our favorite HOFs as well as generics. Until then, we will make do with using the functional programming style as much as possible with a bit of imperative programming where necessary. Another option that we'll explore later is an execution system named Gleam, which provides pure Go mappers and reducers that provide high performance and concurrency.
Data transformations are so common that it's nice to have a shorthand for it. HOF's ability to simplify both writing and reading code that performs data transformations is one of FP's greatest benefits.