Pro Yearly is on sale from $80 to $50! »

FP vs. OOP: Beyond the Bikeshed

FP vs. OOP: Beyond the Bikeshed

In object-oriented languages like Ruby, people often say that “everything is an object”—but first-class functions have become standard for object-oriented languages too. C# has had them and other related features for years, and even Java is in the game these days! Some“functional” languages seem to have some very object-oriented-looking features, too. If that sounds wrong to you, let's talk about polymorphism and more in languages like Clojure, Elixir, and even Haskell! So where does object-oriented programming (OOP) end and functional programming (FP) begin?

In this session, we'll look at these programming paradigms with a more critical eye, focusing on where FP and OOP folks fundamentally disagree, where these paradigms have more in common than the industry's rhetoric suggests, and how we can use those insights to make better decisions about the software we build.

E16bc9c356b65d61ee1d74c8f06ae35b?s=128

Colin Jones

March 22, 2018
Tweet

Transcript

  1. 8th Light, Inc. FP vs. OOP: Beyond the Bikeshed Colin

    Jones @trptcolin https://8thlight.com
  2. agenda bikesheds definitions details conclusions

  3. bikesheds

  4. 8th Light, Inc. Bikeshed picture

  5. C. Northcote Parkinson

  6. Parkinson’s Law of Triviality

  7. committee meeting / argument picture

  8. 8th Light, Inc. Nuclear plant picture

  9. 8th Light, Inc. Bike shed picture

  10. bikesheds

  11. None
  12. http://bikeshed.com/

  13. http://bikeshed.com/

  14. http://bikeshed.com/

  15. http://bikeshed.com/

  16. FP vs. OOP

  17. axes of antipathy

  18. dynamic vs. static

  19. threads vs. processes

  20. vertical scaling vs. horizontal scaling

  21. synchronous vs. asynchronous

  22. convention vs. configuration

  23. easy vs. simple

  24. we could go on…

  25. what’s to be done?

  26. FP vs. OOP

  27. FP’ers say…

  28. OOP is overcomplicated: dozens of classes for the simplest task

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

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

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

  32. FP is for everybody FP’ers say:

  33. OOP’ers say…

  34. FP is concrete dependencies everywhere, needlessly convoluted, callback hell OOP’ers

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

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

    say:
  37. You have to be really smart to use FP well

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

  39. OOP is for everybody OOP’ers say:

  40. whew

  41. definitions

  42. OOP

  43. classes and objects OOP

  44. inheritance, polymorphism, and encapsulation OOP

  45. "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
  46. "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
  47. "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
  48. "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
  49. FP

  50. programming with mathematical functions FP

  51. first-class functions FP

  52. avoiding side effects FP

  53. immutability FP

  54. avoiding side causes FP

  55. whew

  56. details

  57. languages

  58. Java C# Ruby Python JavaScript Haskell Clojure Elixir Erlang Scala

  59. features

  60. 8th Light, Inc. Volkswagen bug picture

  61. FP features

  62. first-class functions FP

  63. first-class functions FP OOP

  64. laziness FP FP

  65. laziness FP FP OOP

  66. persistent data structures / immutability FP FP

  67. persistent data structures / immutability FP FP OOP

  68. OOP features

  69. classes OOP

  70. namespacing OOP

  71. namespacing OOP FP

  72. data containment OOP

  73. data containment OOP FP

  74. messaging OOP

  75. messaging OOP FP

  76. polymorphism OOP

  77. polymorphism OOP FP

  78. encapsulation OOP

  79. encapsulation OOP FP

  80. state management OOP

  81. state management OOP FP

  82. inheritance OOP

  83. inheritance OOP FP?

  84. inheritance OOP? FP?

  85. unique features

  86. pattern matching FP

  87. reified effects? FP

  88. tail recursion optimization FP

  89. 1-letter variable names? FP

  90. 1-letter variable names? FP? OOP?

  91. OOP classes and objects

  92. OOP 3000-line files?

  93. 3000-line files? FP OOP

  94. features?

  95. constraints

  96. avoid side effects avoid side causes FP

  97. OOP avoid doing all the work avoid exposing internals avoid

    concrete dependencies
  98. conclusions

  99. emphasis

  100. OOP messaging encapsulation polymorphism

  101. explicit causes & explicit effects FP

  102. FP and OOP are mostly orthogonal choices

  103. plurality

  104. focus

  105. extrapolating

  106. precision

  107. charity

  108. 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
  109. 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
  110. 8th Light, Inc. Thank you! Colin Jones @trptcolin https://8thlight.com