7. There’s something about the
culture of software that has
impeded the use of
specification. We have a
wonderful way of describing
things precisely that has been
developed over the last couple
of millennia, and it’s called
Mathematics.
-- Leslie Lamport,
Turing Award Winner, 2013.
8. what does FP bring to the table?
good code
easy to read
easy to understand
easy to test
easy to maintain
9. insanity!
doing the same thing over
and over again, and
expecting different
results!
--Albert Einstein
launchMissiles();
=> destroys enemy units
launchMissiles();
=> throws OutOfMissilesException
10. what is FP?
lambda calculus
id(x) = x
x -> x
square_sum(x, y) = x * x + y * y
(x, y) -> x * x + y * y
x -> (y -> (x * x + y * y))
11. confused? let’s make it simple!
pure functions, no side effects
also, higher order functions
12. what’s a function?
a mapping,
each input mapped to exactly
one output,
domain co-domain
14. public Integer square(Integer n)
{
n = n * n;
return n;
}
mutation, side effecting => impure
public Integer square(Integer n)
{
return n * n;
}
no side effect, does only one thing => pure