翻译: A practical introduction to functional programming
oldratlee opened this issue · 1 comments
A practical introduction to functional programming
https://maryrosecook.com/blog/post/a-practical-introduction-to-functional-programming
信息来源
来自非常好的FP
书籍《Functional Programming,Simplified(Scala edition)》 ❤️
Chapter - What is “Functional Programming”? / Section - Proof: A wonderful quote from Mary Rose Cook:
When I first started learning FP, I was aware that pure functions were important, but this point was really driven home when I came across an article titled A Practical Introduction to Functional Programming by Mary Rose Cook.
Ms. Cook used to work at the Recurse Center (formerly known as “Hacker School”) and now works at Makers Academy, and in her “Practical Introduction to FP” essay, she refers to using only pure functions as a Guide Rope to learning FP:
When people talk about functional programming, they mention a dizzying number of ‘functional’ characteristics. They mention immutable data, first class functions, and tail call optimisation. These are language features that aid functional programming.
They mention mapping, reducing, pipelining, recursing, currying and the use of higher order functions. These are programming techniques used to write functional code.
They mention parallelization, lazy evaluation, and determinism. These are advantageous properties of functional programs.
Ignore all that. Functional code is characterised by one thing: the absence of side effects. It (a pure function) doesn’t rely on data outside the current function, and it doesn’t change data that exists outside the current function. Every other ‘functional’ thing can be derived from this property. Use it as a guide rope as you learn.
When she writes about the “absence of side effects,” she’s referring to building applications from pure functions.
Her guide rope statement is so good, it bears repeating:
Functional code is characterised by one thing: the absence of side effects.
When I first read this quote, the little light bulb went on over my head and I began focusing even more on writing only pure functions.
If you think about it, this statement means exactly what I wrote at the beginning of this lesson:
Functional programming is a way of writing software applications using only pure functions and immutable values.