Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Oops! OOP's Not What I Thought

Oops! OOP's Not What I Thought

(Presented at Øredev 2018, DomCode 2016)

In this talk we'll go on a historical and philosophical journey deep into the heart of object-oriented programming (OOP). Come along with me as I have my world shaken by the discovery that objects and classes are not the most important concepts in OOP: messages and late binding are. Join me as we try to peek inside the heads of Alan Kay and the other founders of the paradigm as they were developing early object-oriented languages like Smalltalk, only to discover that those "old" ideas seem strikingly relevant today. We may even feel our jaws drop as we realize that OOP and functional programming are not as different as we may have thought, and that the first object-oriented language was not created in the 60's or 70's but much, much earlier…

What awaits us at the end of this journey? At worst, we'll experience a brief crisis of faith in everything we ever thought we knew about programming. (A support group will meet after the conference.) At best, we'll shift the way we view this near-ubiquitous but oft-misunderstood programming paradigm, and walk away with new insights for how we architect and understand our code.

654527a5cff1756177ef0b1bb0af7aa3?s=128

Anjana Sofia Vakil

November 04, 2016
Tweet

More Decks by Anjana Sofia Vakil

Other Decks in Programming

Transcript

  1. oops! OOP’s not what I thought @AnjanaVakil Øredev 2018

  2. @AnjanaVakil hi, I’m Anjana! - philosophy grad - English language

    teacher - computational linguist - software developer
  3. @AnjanaVakil hi, I’m Anjana! live location data platform for developers

    mapbox.com
  4. @AnjanaVakil hi, I’m Anjana! events.mozilla.org /techspeakers outreachy.org

  5. @AnjanaVakil hi, I’m Anjana! The Recurse Center recurse.com

  6. @AnjanaVakil hi, I’m Anjana! ...and I had OOP all wrong

  7. @AnjanaVakil object- oriented programming objects (!) classes inheritance hierarchy C++,

    Java
  8. @AnjanaVakil object- oriented programming objects (!) classes inheritance hierarchy C++,

    Java
  9. @AnjanaVakil object- oriented programming ?

  10. @AnjanaVakil Photo by Marcin Wichary from San Francisco, U.S.A. (Alan

    Kay and the prototype of Dynabook, pt. 5) [CC BY 2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons Alan Kay @AnjanaVakil
  11. @AnjanaVakil Alan Kay coiner of “object- oriented” @AnjanaVakil

  12. @AnjanaVakil Alan Kay (co-)creator of Smalltalk @AnjanaVakil

  13. @AnjanaVakil Alan Kay personal computing pioneer Dynabook @AnjanaVakil

  14. @AnjanaVakil Alan Kay undergrad biology major @AnjanaVakil

  15. @AnjanaVakil biological metaphors oops #1:

  16. @AnjanaVakil what I thought inheritance taxonomy

  17. @AnjanaVakil what it is cells organs

  18. @AnjanaVakil procedural imperative “Clocks Gears Wallpaper” via Wallpoper (http://wallpoper.com/images/00/38/51/35/clocks-gears_00385135.jpg) @AnjanaVakil

  19. @AnjanaVakil object- oriented “Slide of the Week: Increased WBC, April

    14, 2011” via Center for Genomic Pathology (http://ctrgenpath.net/wp-content/uploads/2011/04/cml02.jpg) @AnjanaVakil
  20. @AnjanaVakil

  21. @AnjanaVakil

  22. @AnjanaVakil big ideas oops #2:

  23. @AnjanaVakil what I thought objects(!) classes

  24. @AnjanaVakil Alan Kay “I'm sorry that I long ago coined

    the term "objects" for this topic because it gets many people to focus on the lesser idea. @AnjanaVakil
  25. @AnjanaVakil Alan Kay “The big idea is "messaging"” - To

    Smalltalk/Squeak mailing list, 1998 wiki.c2.com/?AlanKayOnMessaging @AnjanaVakil
  26. @AnjanaVakil what it is messaging late-binding

  27. @AnjanaVakil objects @AnjanaVakil

  28. @AnjanaVakil messages “Dopamine D3 receptor” via Orientation of Proteins in

    Membranes Database (http://opm.phar.umich.edu/images/png/3pbl.png) @AnjanaVakil
  29. @AnjanaVakil systems Image by The Opte Project (Internet Map) [CC

    BY 2.5 (http://creativecommons.org/licenses/by/2.5)], via Wikimedia Commons @AnjanaVakil
  30. @AnjanaVakil thing.do(some,stuff)

  31. @AnjanaVakil to: thing subject: pretty please? :D message: "do", some,

    stuff
  32. @AnjanaVakil recipient message thing.do(some,stuff)

  33. @AnjanaVakil recipient message thing.do(some,stuff) method name arguments

  34. @AnjanaVakil Ruby thing.do(some,stuff) thing.send(:do,some,stuff)

  35. @AnjanaVakil what does do do? how? thing.do(some,stuff) thing.do(other,stuff) child.do(some,stuff) thing.do(some,stuff)

  36. @AnjanaVakil early binding @AnjanaVakil

  37. @AnjanaVakil late binding @AnjanaVakil

  38. @AnjanaVakil beings vs. behaviors oops #3:

  39. @AnjanaVakil what I thought objects are nouns

  40. @AnjanaVakil what it is objects are verbs

  41. @AnjanaVakil data @AnjanaVakil

  42. @AnjanaVakil behavior @AnjanaVakil

  43. @AnjanaVakil thing.do(stuff) => behavior

  44. @AnjanaVakil class Friend: def __init__(self, friends): self.friends = friends def

    is_friend_of(self, name): return name in self.friends buddy = Friend(['alan', 'alonzo']) buddy.is_friend_of('guy') => False
  45. @AnjanaVakil buddy.is_friend_of('guy') buddy.send(:is_friend_of, 'guy')

  46. @AnjanaVakil buddy.is_friend_of('guy') buddy.send(:is_friend_of, 'guy') buddy('is_friend_of', 'guy')

  47. @AnjanaVakil def Friend(friend_names): my_friends = friend_names def is_my_friend(name): return name

    in friend_names def responder(method_name, *args): if method_name == 'is_friend_of': return is_my_friend(args) return responder buddy = Friend(['alan', 'alonzo']) buddy('is_friend_of','guy') => False
  48. @AnjanaVakil def Friend(friend_names): my_friends = friend_names def is_my_friend(name): return name

    in friend_names def buddy(method_name, *args): if method_name == 'is_friend_of': return is_my_friend(*args) return responder buddy = Friend(['alan', 'alonzo']) buddy('is_friend_of','guy') => False
  49. @AnjanaVakil def Friend(friend_names): my_friends = friend_names def is_my_friend(name): return name

    in friend_names def buddy(method_name, *args): if method_name == 'is_friend_of': return is_my_friend(*args) return responder buddy = Friend(['alan', 'alonzo']) buddy('is_friend_of','guy') => False
  50. @AnjanaVakil def Friend(friend_names): my_friends = friend_names def is_my_friend(name): return name

    in friend_names def responder(method_name, *args): if method_name == 'is_friend_of': return is_my_friend(*args) return responder buddy = Friend(['alan', 'alonzo']) buddy('is_friend_of','guy') => False
  51. @AnjanaVakil boundaries oops #4:

  52. @AnjanaVakil what I thought imperative ---------- object-otd ========== functional

  53. @AnjanaVakil what it is imperative ========== object-otd ---------- functional

  54. @AnjanaVakil Smalltalk class True ifTrue: a ifFalse: b ^ a

    value class False ifTrue: a ifFalse: b ^ b value
  55. @AnjanaVakil Smalltalk class True ifTrue: a ifFalse: b ^ a

    value class False ifTrue: a ifFalse: b ^ b value Lambda calculus TRUE := λx.λy.x FALSE := λx.λy.y
  56. @AnjanaVakil Erlang Fred Hébert Learn You Some Erlang for Great

    Good learnyousomeerlang.com
  57. @AnjanaVakil JS "callbags" André Stalz "Callback Heaven", Amsterdam JSNation 2018

    youtu.be/HssczgaY9BM
  58. @AnjanaVakil belief structures oops #5:

  59. @AnjanaVakil what I thought dogmatic restrictive

  60. @AnjanaVakil what it is built for change *or should be

  61. @AnjanaVakil simplicity complexity @AnjanaVakil

  62. @AnjanaVakil resilience @AnjanaVakil

  63. @AnjanaVakil scalability @AnjanaVakil

  64. @AnjanaVakil Alan Kay: - The early history of Smalltalk worrydream.com/EarlyHistoryOfSmalltalk

    - Comment on Moti Ben-Ari's Objects never? Well, hardly ever! computinged.wordpress.com/2010/09/11/moti-asks-objects-never-well-hardly-ever/#div-comment-3766 - E-mail to Stefan Ram on definition of OOP purl.org/stefan_ram/pub/doc_kay_oop_en - E-mail to Squeak list on "messaging" wiki.c2.com/?AlanKayOnMessaging William Cook: - A Proposal for Simplified, Modern Definitions of "Object" and "Object Oriented" wcook.blogspot.com/2012/07/proposal-for-simplified-modern.html - On Understanding Data Abstraction, Revisited cs.utexas.edu/%7Ewcook/Drafts/2009/essay.pdf Anjana Vakil, "Programming across Paradigms" youtu.be/uNPdZm5oF_E Andre Stalz, "Why we need callbags" staltz.com/why-we-need-callbags Structure & Interpretation of Computer Programs mitpress.mit.edu/sicp Learn You Some Erlang for Great Good learnyousomeerlang.com further reading & references
  65. David Albert, Darius Bacon, Lindsey Kuper, Julia Evans, Matthew Parker,

    Ezekiel Smithburg, Juan Hernández, Andy Lee, Michael Arntzenius & the Recurse Center Team Øredev thank you! @AnjanaVakil