![Page 1: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/1.jpg)
NEAL FORD software architect / meme wrangler
ThoughtWorks®
[email protected] 3003 Summit Boulevard, Atlanta, GA 30319 www.nealford.com www.thoughtworks.com blog: memeagora.blogspot.com twitter: neal4d
Functional Thinking
![Page 2: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/2.jpg)
3 metaphors^tortured
![Page 3: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/3.jpg)
x = x + 1solve for x?
:assign to x
![Page 4: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/4.jpg)
![Page 5: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/5.jpg)
![Page 6: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/6.jpg)
languages are tools.
Learning a new one takes time.
Paradigms
![Page 7: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/7.jpg)
“functional” is more a way of thinking than
a tool set
“functional” is more a way of thinking than
a tool set
![Page 8: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/8.jpg)
Execution in the Kingdomof Nouns
Steve Yeggehttp://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html
![Page 9: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/9.jpg)
v e r b s !
![Page 10: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/10.jpg)
"OOP makes working with state easier.
FP makes eliminating state
easier"OH on
![Page 11: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/11.jpg)
OO makes code understandable by
encapsulating moving parts.
FP makes code understandable by minimizing moving
parts.Michael Feathers, author of “Working with Legacy Code”
![Page 12: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/12.jpg)
numberclassification
![Page 13: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/13.jpg)
perfect #
(sum of the factors of a #) - # = #
(sum of the factors of a #) = 2#
6: 1 + 2 + 3 + 6 = 12 (2x6)28: 1 + 2 + 4 + 7 + 14 + 28 = 56 (2x28)496: . . .
∑(f(#)) - # = #
![Page 14: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/14.jpg)
classification
∑(f(#)) = 2# perfect
∑(f(#)) > 2# abundant
∑(f(#)) < 2# deficient
![Page 15: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/15.jpg)
imperative
![Page 16: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/16.jpg)
![Page 17: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/17.jpg)
![Page 18: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/18.jpg)
2
8
![Page 19: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/19.jpg)
![Page 20: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/20.jpg)
![Page 21: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/21.jpg)
internal state
cohesive
composed
testable
refactorable
![Page 22: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/22.jpg)
(slightly more)functional
![Page 23: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/23.jpg)
![Page 24: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/24.jpg)
![Page 25: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/25.jpg)
![Page 26: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/26.jpg)
![Page 27: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/27.jpg)
no internal state
less need for scoping testablerefactorable
![Page 28: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/28.jpg)
“functional” is more a way of thinking than
a tool set
“functional” is more a way of thinking than
a tool set
![Page 29: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/29.jpg)
concepts
1st classfunctions
high-orderfunctions
pure functions
recursion
strict evaluation
1st classfunctions
purefunctions
high-orderfunctionsrecursion
strict evaluation
![Page 30: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/30.jpg)
high-order functions
![Page 31: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/31.jpg)
high-order functions
functions that can either take other
functions as arguments or return
them as results
![Page 32: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/32.jpg)
![Page 33: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/33.jpg)
![Page 34: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/34.jpg)
![Page 35: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/35.jpg)
!
![Page 36: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/36.jpg)
closuresWhat’s so special about...
![Page 37: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/37.jpg)
![Page 38: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/38.jpg)
![Page 39: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/39.jpg)
let the language
manage state
let the language
manage state
![Page 40: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/40.jpg)
concurrency
memory allocation
garbage collection
tests
state
languages handle
time
specification-based testing frameworks
![Page 41: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/41.jpg)
1st-class functions
![Page 42: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/42.jpg)
1st-class functionsfunctions can
appear anywhere other language constructs can
appear
![Page 43: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/43.jpg)
![Page 44: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/44.jpg)
![Page 45: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/45.jpg)
![Page 46: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/46.jpg)
think about results, not steps
think about results, not steps
![Page 47: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/47.jpg)
1 2 3 4 5 6 7 8 9 10 11 12
121 2 3 4 6 12
![Page 48: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/48.jpg)
think about results, not steps
think about results, not steps
![Page 49: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/49.jpg)
![Page 50: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/50.jpg)
list comprehension
(number + 1)range from 1 to for each n in
filter list by criteria my is-factor? functionreturn the numbers that match
return the list as a set
![Page 51: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/51.jpg)
![Page 52: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/52.jpg)
composition
![Page 53: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/53.jpg)
academia alert!
![Page 54: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/54.jpg)
curryinggiven:
then:
currying takes a function with a particular number of parameters and returns a
function with some of the parameter values fixed, creating a new function
![Page 55: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/55.jpg)
return a version that always multiplies by 4
==
![Page 56: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/56.jpg)
![Page 57: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/57.jpg)
new, different tools
function reuse
new, different tools
![Page 58: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/58.jpg)
currying
![Page 59: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/59.jpg)
pure functions
![Page 60: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/60.jpg)
pure functions
no memory or i/o side effects
![Page 61: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/61.jpg)
enables memoization
if the result isn’t used, it can be removed
a particular invocation with a set of parameters returns a constant value
parallel execution
execution order can change
purity
![Page 62: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/62.jpg)
recursion
![Page 63: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/63.jpg)
iterative filtering
![Page 64: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/64.jpg)
recursive filtering
think about results, not steps
think about results, not steps
http://www.scala-lang.org/node/135
![Page 65: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/65.jpg)
think about results, not steps
think about results, not steps
what about things you want to control?
performance?
new, different tools
new, different tools
![Page 66: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/66.jpg)
imperative number classifier
optimized!
![Page 67: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/67.jpg)
optimized factors
think about results, not steps
think about results, not steps
![Page 68: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/68.jpg)
ingrained imperativity
Google challenged college grads to write code for 100 CPU computers...
...they failed
sound familiar?
learn MapReduce
post-imperative
http://broadcast.oreilly.com/2008/11/warning-x-x-1-may-be-hazardous.html
http://code.google.com/edu/submissions/mapreduce-minilecture/listing.html
![Page 69: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/69.jpg)
state
garbage collection
concurrency
. . .
tests
languages handle
time
iteration
![Page 70: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/70.jpg)
strict evaluation
![Page 71: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/71.jpg)
academia alert!
![Page 72: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/72.jpg)
all elementspre-evaluated
elements evaluatedas needed
strictevaluation
non-strictevaluation
divByZero
=4
![Page 73: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/73.jpg)
laziness
![Page 74: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/74.jpg)
([1001 7927] [1002 7933] [1003 7937] [1004 7949] [1005 7951])
new, different tools
new, different tools
![Page 75: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/75.jpg)
concurrency
![Page 76: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/76.jpg)
no effect on the world
depend only on their arguments
given the same arguments, return the same values
no notion of time
functions:
![Page 77: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/77.jpg)
wait for external events
expect change over time
affect the world
produce different answers at different times
most programs are processes
![Page 78: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/78.jpg)
what can we add to functional
programming to deal with processes?
![Page 79: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/79.jpg)
non-composable
assume 1 thread of control, 1 timeline
not atomic
with concurrency: lock & pray
subtle visibility rules
variables
![Page 80: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/80.jpg)
life w/ variables
variable
???
variable
???
?
![Page 81: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/81.jpg)
identity
identity value
identity value
value
explicit semantic
state
![Page 82: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/82.jpg)
identity, state, & time
term meaning
value immutable data in a persistent data structure
identity series of causally related values over time
state identity at a point in time
timerelative: before/simultaneous/after ordering of causal values
![Page 83: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/83.jpg)
epochal time model
v1
F
v2
F
v3
F
v4
Process events (pure functions)
Observers/perception/memory
States (immutable values)Identity
(succession of states)
![Page 84: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/84.jpg)
actors
![Page 85: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/85.jpg)
new, different tools
new, different tools
![Page 86: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/86.jpg)
thinking functionally
![Page 87: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/87.jpg)
immutabilityover
state transitions
http://www.ibm.com/developerworks/java/library/j-jtp02183/index.html
![Page 88: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/88.jpg)
resultsoversteps
![Page 89: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/89.jpg)
compositionover
structure
![Page 90: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/90.jpg)
declarative over
imperative
![Page 91: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/91.jpg)
paradigmover tool
![Page 92: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/92.jpg)
summary
![Page 93: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/93.jpg)
immediately beneficial beginning steps
new ways of thinking about design
new tools for extension, reuse, etc.
enables entirely new capabilities
following the general trend in language design
functional thinking
![Page 94: Functional Thinking - 33rd Degree33degree.org/pdf/NealFordFuntionalThinking.pdf · OH on . OO makes code understandable by encapsulating moving parts. FP makes code ... affect the](https://reader033.vdocument.in/reader033/viewer/2022052020/603402f3611ae5723a743a0a/html5/thumbnails/94.jpg)
This work is licensed under the Creative Commons Attribution-Share Alike 3.0 License.
http://creativecommons.org/licenses/by-sa/3.0/us/
?’splease fill out the session evaluations
NEAL FORD software architect / meme wrangler
ThoughtWorks®
[email protected] 3003 Summit Boulevard, Atlanta, GA 30319 www.nealford.com www.thoughtworks.com blog: memeagora.blogspot.com twitter: neal4d