Slide 1

Slide 1 text

8th Light, Inc. FP vs. OOP: Beyond the Bikeshed Colin Jones @trptcolin https://8thlight.com

Slide 2

Slide 2 text

agenda bikesheds definitions details conclusions

Slide 3

Slide 3 text

bikesheds

Slide 4

Slide 4 text

8th Light, Inc. Bikeshed picture

Slide 5

Slide 5 text

C. Northcote Parkinson

Slide 6

Slide 6 text

Parkinson’s Law of Triviality

Slide 7

Slide 7 text

committee meeting / argument picture

Slide 8

Slide 8 text

8th Light, Inc. Nuclear plant picture

Slide 9

Slide 9 text

8th Light, Inc. Bike shed picture

Slide 10

Slide 10 text

bikesheds

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

http://bikeshed.com/

Slide 13

Slide 13 text

http://bikeshed.com/

Slide 14

Slide 14 text

http://bikeshed.com/

Slide 15

Slide 15 text

http://bikeshed.com/

Slide 16

Slide 16 text

FP vs. OOP

Slide 17

Slide 17 text

axes of antipathy

Slide 18

Slide 18 text

dynamic vs. static

Slide 19

Slide 19 text

threads vs. processes

Slide 20

Slide 20 text

vertical scaling vs. horizontal scaling

Slide 21

Slide 21 text

synchronous vs. asynchronous

Slide 22

Slide 22 text

convention vs. configuration

Slide 23

Slide 23 text

easy vs. simple

Slide 24

Slide 24 text

we could go on…

Slide 25

Slide 25 text

what’s to be done?

Slide 26

Slide 26 text

FP vs. OOP

Slide 27

Slide 27 text

FP’ers say…

Slide 28

Slide 28 text

OOP is overcomplicated: dozens of classes for the simplest task FP’ers say:

Slide 29

Slide 29 text

OOP means a big ball of mud FP’ers say:

Slide 30

Slide 30 text

It’s impossible to use OOP well FP’ers say:

Slide 31

Slide 31 text

FP is about making systems easier to understand FP’ers say:

Slide 32

Slide 32 text

FP is for everybody FP’ers say:

Slide 33

Slide 33 text

OOP’ers say…

Slide 34

Slide 34 text

FP is concrete dependencies everywhere, needlessly convoluted, callback hell OOP’ers say:

Slide 35

Slide 35 text

FP is concrete dependencies everywhere, needlessly convoluted, callback hell OOP’ers say:

Slide 36

Slide 36 text

FP is concrete dependencies everywhere, needlessly convoluted, callback hell OOP’ers say:

Slide 37

Slide 37 text

You have to be really smart to use FP well OOP’ers say:

Slide 38

Slide 38 text

OOP is about making systems easier to understand OOP’ers say:

Slide 39

Slide 39 text

OOP is for everybody OOP’ers say:

Slide 40

Slide 40 text

whew

Slide 41

Slide 41 text

definitions

Slide 42

Slide 42 text

OOP

Slide 43

Slide 43 text

classes and objects OOP

Slide 44

Slide 44 text

inheritance, polymorphism, and encapsulation OOP

Slide 45

Slide 45 text

"OOP to me means only messaging, local retention and protection and
 hiding of state-process, and extreme late-binding of all things.” - Alan Kay OOP

Slide 46

Slide 46 text

"OOP to me means only messaging, local retention and protection and
 hiding of state-process, and extreme late-binding of all things.” - Alan Kay OOP

Slide 47

Slide 47 text

"OOP to me means only messaging, local retention and protection and
 hiding of state-process, and extreme late-binding of all things.” - Alan Kay OOP

Slide 48

Slide 48 text

"OOP to me means only messaging, local retention and protection and
 hiding of state-process, and extreme late-binding of all things.” - Alan Kay OOP

Slide 49

Slide 49 text

FP

Slide 50

Slide 50 text

programming with mathematical functions FP

Slide 51

Slide 51 text

first-class functions FP

Slide 52

Slide 52 text

avoiding side effects FP

Slide 53

Slide 53 text

immutability FP

Slide 54

Slide 54 text

avoiding side causes FP

Slide 55

Slide 55 text

whew

Slide 56

Slide 56 text

details

Slide 57

Slide 57 text

languages

Slide 58

Slide 58 text

Java C# Ruby Python JavaScript Haskell Clojure Elixir Erlang Scala

Slide 59

Slide 59 text

features

Slide 60

Slide 60 text

8th Light, Inc. Volkswagen bug picture

Slide 61

Slide 61 text

FP features

Slide 62

Slide 62 text

first-class functions FP

Slide 63

Slide 63 text

first-class functions FP OOP

Slide 64

Slide 64 text

laziness FP FP

Slide 65

Slide 65 text

laziness FP FP OOP

Slide 66

Slide 66 text

persistent data structures / immutability FP FP

Slide 67

Slide 67 text

persistent data structures / immutability FP FP OOP

Slide 68

Slide 68 text

OOP features

Slide 69

Slide 69 text

classes OOP

Slide 70

Slide 70 text

namespacing OOP

Slide 71

Slide 71 text

namespacing OOP FP

Slide 72

Slide 72 text

data containment OOP

Slide 73

Slide 73 text

data containment OOP FP

Slide 74

Slide 74 text

messaging OOP

Slide 75

Slide 75 text

messaging OOP FP

Slide 76

Slide 76 text

polymorphism OOP

Slide 77

Slide 77 text

polymorphism OOP FP

Slide 78

Slide 78 text

encapsulation OOP

Slide 79

Slide 79 text

encapsulation OOP FP

Slide 80

Slide 80 text

state management OOP

Slide 81

Slide 81 text

state management OOP FP

Slide 82

Slide 82 text

inheritance OOP

Slide 83

Slide 83 text

inheritance OOP FP?

Slide 84

Slide 84 text

inheritance OOP? FP?

Slide 85

Slide 85 text

unique features

Slide 86

Slide 86 text

pattern matching FP

Slide 87

Slide 87 text

reified effects? FP

Slide 88

Slide 88 text

tail recursion optimization FP

Slide 89

Slide 89 text

1-letter variable names? FP

Slide 90

Slide 90 text

1-letter variable names? FP? OOP?

Slide 91

Slide 91 text

OOP classes and objects

Slide 92

Slide 92 text

OOP 3000-line files?

Slide 93

Slide 93 text

3000-line files? FP OOP

Slide 94

Slide 94 text

features?

Slide 95

Slide 95 text

constraints

Slide 96

Slide 96 text

avoid side effects avoid side causes FP

Slide 97

Slide 97 text

OOP avoid doing all the work avoid exposing internals avoid concrete dependencies

Slide 98

Slide 98 text

conclusions

Slide 99

Slide 99 text

emphasis

Slide 100

Slide 100 text

OOP messaging encapsulation polymorphism

Slide 101

Slide 101 text

explicit causes & explicit effects FP

Slide 102

Slide 102 text

FP and OOP are mostly orthogonal choices

Slide 103

Slide 103 text

plurality

Slide 104

Slide 104 text

focus

Slide 105

Slide 105 text

extrapolating

Slide 106

Slide 106 text

precision

Slide 107

Slide 107 text

charity

Slide 108

Slide 108 text

more • Parkinson’s Law of Triviality: https://www.farnamstreetblog.com/2013/12/ parkinsons-law/ • How the term “bikeshed" got into software: http://bikeshed.com • Alan Kay’s definition of OOP: http://www.purl.org/stefan_ram/pub/ doc_kay_oop_en • Kris Jenkins, “What is Functional Programming”: http://blog.jenkster.com/ 2015/12/what-is-functional-programming.html • Stuart Halloway, “Simplicity Made Easy”: https://youtu.be/cidchWg74Y4 • John Hughes, “Why Functional Programming Matters”: https:// www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf

Slide 109

Slide 109 text

more • Gamma/Helm/Johnson/Vlissides (Gang of Four), Design Patterns: http://a.co/ 6OdEq4h • Chris Okasaki, Purely Functional Data Structures: http://a.co/isBRerv • Gary Bernhardt, “Boundaries”: https://www.destroyallsoftware.com/talks/ boundaries • Peter van Roy and Seif Haridi, Concepts, Techniques, and Models of Computer Programming: https://www.info.ucl.ac.be/~pvr/book.html • Gary Bernhardt, “Ideology”: https://www.destroyallsoftware.com/talks/ideology

Slide 110

Slide 110 text

8th Light, Inc. Thank you! Colin Jones @trptcolin https://8thlight.com