Slide 1

Slide 1 text

Types @brixen As Premature Optimization

Slide 2

Slide 2 text

Summary

Slide 3

Slide 3 text

We can't use them well

Slide 4

Slide 4 text

We usually don't need them

Slide 5

Slide 5 text

They can harm more than help

Slide 6

Slide 6 text

Questions?

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Under-specified What if we put the bread on the floor?

Slide 16

Slide 16 text

Imperative Did we just use temporal coupling?

Slide 17

Slide 17 text

Mutable state How will we know what's in the fridge?

Slide 18

Slide 18 text

Repetitive Never heard of DRY?

Slide 19

Slide 19 text

let a = bread! get a from breadbox! ...! spread b on a!

Slide 20

Slide 20 text

Not abstract How are we going to scale?

Slide 21

Slide 21 text

sandwich(:wheat,! :peanut_butter,! :jelly)

Slide 22

Slide 22 text

sandwich(:rye,! :ham,! :swiss)

Slide 23

Slide 23 text

*LTR Purely functional peanut butter & jelly sandwich (Extra credit: use static typing)

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

General purpose

Slide 26

Slide 26 text

Project failure KPMG (New Zealand) - Dec 2010 70% Had project failure in previous 12 months

Slide 27

Slide 27 text

Project failure McKinsey & Company in conjunction with the University of Oxford - 2012 Failure could threaten company 17%

Slide 28

Slide 28 text

0 25 50 75 100 Agile Traditional 67 73 Project success Dr Dobbs Journal - Aug 2007, Oct 2011

Slide 29

Slide 29 text

We don't learn from failure

Slide 30

Slide 30 text

We learn from other's failure

Slide 31

Slide 31 text

Programming is a behavioral science Sorry maths people

Slide 32

Slide 32 text

Perception Is it reality?

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Cognition Is it reality?

Slide 37

Slide 37 text

3 8

Slide 38

Slide 38 text

8 3

Slide 39

Slide 39 text

3 8

Slide 40

Slide 40 text

3 8

Slide 41

Slide 41 text

3 8

Slide 42

Slide 42 text

3 8

Slide 43

Slide 43 text

if even then red

Slide 44

Slide 44 text

if red then even Converse

Slide 45

Slide 45 text

if red then even Converse

Slide 46

Slide 46 text

if ¬even then ¬red Inverse

Slide 47

Slide 47 text

if ¬even then ¬red Inverse

Slide 48

Slide 48 text

if ¬red then ¬even Contrapositive

Slide 49

Slide 49 text

3 8

Slide 50

Slide 50 text

People who gave incorrect response 90%

Slide 51

Slide 51 text

Propositions as types

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Statisticians

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

Correct by construction

Slide 57

Slide 57 text

We can't use them well

Slide 58

Slide 58 text

Eight fallacies of programming

Slide 59

Slide 59 text

Same scale 1

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

klocs

Slide 63

Slide 63 text

Same risk 2

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

Same cost 3

Slide 66

Slide 66 text

N * klocs = $

Slide 67

Slide 67 text

Same granularity 4

Slide 68

Slide 68 text

Everything is an object

Slide 69

Slide 69 text

Everything is a function

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

Same abstraction 5

Slide 73

Slide 73 text

Same temporality 6

Slide 74

Slide 74 text

Compile at one point in time

Slide 75

Slide 75 text

Same order 7

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

z → z2 + c

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

They can harm more than help

Slide 82

Slide 82 text

General purpose 8

Slide 83

Slide 83 text

! nil!

Slide 84

Slide 84 text

nil is not null

Slide 85

Slide 85 text

! $ nil.to_s! => ""!

Slide 86

Slide 86 text

! $ nil.to_h! => {}!

Slide 87

Slide 87 text

! $ nil.to_i! => 0!

Slide 88

Slide 88 text

! $ nil.to_c! => (0+0i)!

Slide 89

Slide 89 text

id x = x

Slide 90

Slide 90 text

f(g(h(x)))

Slide 91

Slide 91 text

f(g(h(nil))) = nil

Slide 92

Slide 92 text

class NilClass! def method_missing(*)! self! end! end

Slide 93

Slide 93 text

We usually don't need them

Slide 94

Slide 94 text

! puts "Hello, Barcelona!"!

Slide 95

Slide 95 text

module Kernel! def puts(*args)! # ...! end! ! module_function :puts! end

Slide 96

Slide 96 text

! puts "Hello, Barcelona!"!

Slide 97

Slide 97 text

fun puts(*args)! # ...! end

Slide 98

Slide 98 text

destroyallsoftware.com

Slide 99

Slide 99 text

No content

Slide 100

Slide 100 text

fun add(a, b)! a + b! end

Slide 101

Slide 101 text

fun add(a: int, b: int)! a + b! end

Slide 102

Slide 102 text

load_int 0, r1! load_int 1, r2! add r1, r2, r3! # ^a ^b ^c! store_int r3, 2

Slide 103

Slide 103 text

CLIs

Slide 104

Slide 104 text

parsers JSON • YAML • XML/HTML

Slide 105

Slide 105 text

HTTP parsers

Slide 106

Slide 106 text

Garbage collectors

Slide 107

Slide 107 text

General purpose

Slide 108

Slide 108 text

grammar date do! ...! end

Slide 109

Slide 109 text

a = q r!

Slide 110

Slide 110 text

Try Rubinius github.com/rubinius/rubinius

Slide 111

Slide 111 text

# Gemfile! platforms :mri do! gem "ruby-debug"! end!

Slide 112

Slide 112 text

$ bundle update

Slide 113

Slide 113 text

$ bundle exec puma

Slide 114

Slide 114 text

~2.1

Slide 115

Slide 115 text

1.8.7

Slide 116

Slide 116 text

No content

Slide 117

Slide 117 text

Open source is not a spectator sport

Slide 118

Slide 118 text

No content

Slide 119

Slide 119 text

Don't worry, have fun

Slide 120

Slide 120 text

"Don't worry about people stealing your ideas...

Slide 121

Slide 121 text

"If your ideas are any good, you'll have to ram them down people's throats. —Howard H. Aiken

Slide 122

Slide 122 text

"Sometimes the questions are complicated and the answers are simple" —Dr. Seuss

Slide 123

Slide 123 text

"You never change things by fighting the existing reality...

Slide 124

Slide 124 text

"To change something, build a new model that makes the existing model obsolete." —Buckminster Fuller

Slide 125

Slide 125 text

"No [corporation] can stop an idea whose time has come. —Victor Hugo

Slide 126

Slide 126 text

"Complain about the way other people make software by making software." —Andre Torrez

Slide 127

Slide 127 text

@brixen

Slide 128

Slide 128 text

Thank you!

Slide 129

Slide 129 text

• Chaos: Making a New Science, James Gleick • The Power of Noticing: What the Best Leaders See, Max Bazerman • Smartcuts: How Hackers, Innovators, and Icons Accelerate Success, Shane Snow • You Are Not So Smart, David McRaney • You Are Now Less Dumb, David McRaney • Research Methods: The Basics, Nicholas Walliman • The Art of Thinking Clearly, Rolf Dobelli • Thinking, Fast and Slow, Daniel Kahneman • Intertwingled: Information Changes Everything, Peter Morville • https://en.wikipedia.org/wiki/Cynefin • http://calleam.com/WTPF/?page_id=1445 References

Slide 130

Slide 130 text

• http://commons.wikimedia.org/wiki/File:Peanut-Butter-Jelly-Sandwich.png • https://c1.staticflickr.com/5/4030/4695047698_9fd2da8a9f_z.jpg • http://www.teacher-chef.com/wp-content/uploads/2013/03/3-2013-peanut-butter.jpg • http://upload.wikimedia.org/wikipedia/commons/f/f6/Marmite_thick_spread_toasted_bread.jpg • http://farm3.staticflickr.com/2661/3725885335_61ef015d61_b.jpg • http://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Peanut_butter_and_jelly_sandwich.jpg/ 1024px-Peanut_butter_and_jelly_sandwich.jpg • https://en.wikipedia.org/wiki/Oracle_OpenWorld • http://upload.wikimedia.org/wikipedia/commons/8/86/Ever_Given_container_ship.jpg • http://www.kenrockwell.com/trips/2010-05-nyc/6-01/IMG_7652-po-boxes.jpg • http://clubs1.bg/images/uploads/1237936572timo-glock-driving-with-toyota-hilux-stunt-team-in- melbourne_2.jpg • http://aviewfrommyseat.com/photos/newsmatt-20130923094556.jpg • http://upload.wikimedia.org/wikipedia/commons/1/15/Zombie_costume_portrait.jpg • http://upload.wikimedia.org/wikipedia/commons/d/de/Mandelbrot_set_rainbow_colors.png • http://4.bp.blogspot.com/_GvajRDbRRO4/TLmBW9Kdq5I/AAAAAAAAAp4/q6lyHTE1AuE/s1600/ Mandel_zoom_11_satellite_double_spiral.jpg • http://paulbourke.net/fractals/lorenz/lorenz4.png • http://upload.wikimedia.org/wikipedia/commons/3/39/MashedPotatoes.jpg • http://pixabay.com/static/uploads/photo/2013/03/29/16/27/book-97709_640.jpg Credits