I was looking for F# book Bedok National Library, but couldn’t find it. So I borrowed this book instead.
After finishing it, I can’t say I like it. Maybe because the book is aimed towards Java programmers (the functional part is done in Groovy/Scala). But at least I was not totally wasted my time. I picked up few things, mostly on the concept of functional programming. Here’s what I learned from this book.
Why Functional Programming?
Should we learn Functional Programming (FP)? Apparently yes. Here’s why:
- We can closely model the solution exactly like how we would solve it in our brain
- FP allows us to closely mirrors the mathematical function which in turn allows us to design stronger algorithm
Feature of Functional Programming
- First class function: function which takes function as parameter, or returns a function.
- Pure function: function that has no side effects
- Recursion: function which calls itself
- Immutable variables: variables which once set, the value can’t be changed
- Non-strict (lazy-loading) evaluation: only produce the result when the the result is consummated
- Pattern matching: match the variable’s value to a pattern.
- Anonymous function: function which don’t need to give name. E.g. Lambda function.
- Closures: a type of anonymous function which is used as a function factory. Using closure, we can easily build functions then pass them to other functions while referring to local variables
The book was quite thin for a programming book standard 😀 I found the book quite easy to follow. Maybe because I have accidentally familiar with functional concepts used in jQuery.