Types As Premature Optimization

A8e44ce1b57c2689d5a7172d15df42b5?s=47 brixen
September 13, 2014

Types As Premature Optimization

Presented at Barcelona Ruby Conference 2014

A8e44ce1b57c2689d5a7172d15df42b5?s=128

brixen

September 13, 2014
Tweet

Transcript

  1. Types @brixen As Premature Optimization

  2. Summary

  3. We can't use them well

  4. We usually don't need them

  5. They can harm more than help

  6. Questions?

  7. None
  8. None
  9. None
  10. None
  11. None
  12. None
  13. None
  14. None
  15. Under-specified What if we put the bread on the floor?

  16. Imperative Did we just use temporal coupling?

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

  18. Repetitive Never heard of DRY?

  19. let a = bread! get a from breadbox! ...! spread

    b on a!
  20. Not abstract How are we going to scale?

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

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

  23. *LTR Purely functional peanut butter & jelly sandwich (Extra credit:

    use static typing)
  24. None
  25. General purpose

  26. Project failure KPMG (New Zealand) - Dec 2010 70% Had

    project failure in previous 12 months
  27. Project failure McKinsey & Company in conjunction with the University

    of Oxford - 2012 Failure could threaten company 17%
  28. 0 25 50 75 100 Agile Traditional 67 73 Project

    success Dr Dobbs Journal - Aug 2007, Oct 2011
  29. We don't learn from failure

  30. We learn from other's failure

  31. Programming is a behavioral science Sorry maths people

  32. Perception Is it reality?

  33. None
  34. None
  35. None
  36. Cognition Is it reality?

  37. 3 8

  38. 8 3

  39. 3 8

  40. 3 8

  41. 3 8

  42. 3 8

  43. if even then red

  44. if red then even Converse

  45. if red then even Converse

  46. if ¬even then ¬red Inverse

  47. if ¬even then ¬red Inverse

  48. if ¬red then ¬even Contrapositive

  49. 3 8

  50. People who gave incorrect response 90%

  51. Propositions as types

  52. None
  53. None
  54. Statisticians

  55. None
  56. Correct by construction

  57. We can't use them well

  58. Eight fallacies of programming

  59. Same scale 1

  60. None
  61. None
  62. klocs

  63. Same risk 2

  64. None
  65. Same cost 3

  66. N * klocs = $

  67. Same granularity 4

  68. Everything is an object

  69. Everything is a function

  70. None
  71. None
  72. Same abstraction 5

  73. Same temporality 6

  74. Compile at one point in time

  75. Same order 7

  76. None
  77. None
  78. z → z2 + c

  79. None
  80. None
  81. They can harm more than help

  82. General purpose 8

  83. ! nil!

  84. nil is not null

  85. ! $ nil.to_s! => ""!

  86. ! $ nil.to_h! => {}!

  87. ! $ nil.to_i! => 0!

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

  89. id x = x

  90. f(g(h(x)))

  91. f(g(h(nil))) = nil

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

  93. We usually don't need them

  94. ! puts "Hello, Barcelona!"!

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

    end
  96. ! puts "Hello, Barcelona!"!

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

  98. destroyallsoftware.com

  99. None
  100. fun add(a, b)! a + b! end

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

  102. load_int 0, r1! load_int 1, r2! add r1, r2, r3!

    # ^a ^b ^c! store_int r3, 2
  103. CLIs

  104. parsers JSON • YAML • XML/HTML

  105. HTTP parsers

  106. Garbage collectors

  107. General purpose

  108. grammar date do! ...! end

  109. a = q r!

  110. Try Rubinius github.com/rubinius/rubinius

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

  112. $ bundle update

  113. $ bundle exec puma

  114. ~2.1

  115. 1.8.7

  116. None
  117. Open source is not a spectator sport

  118. None
  119. Don't worry, have fun

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

  121. "If your ideas are any good, you'll have to ram

    them down people's throats. —Howard H. Aiken
  122. "Sometimes the questions are complicated and the answers are simple"

    —Dr. Seuss
  123. "You never change things by fighting the existing reality...

  124. "To change something, build a new model that makes the

    existing model obsolete." —Buckminster Fuller
  125. "No [corporation] can stop an idea whose time has come.

    —Victor Hugo
  126. "Complain about the way other people make software by making

    software." —Andre Torrez
  127. @brixen

  128. Thank you!

  129. • 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
  130. • 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