Jon Aquino's Mental Garden

Engineering beautiful software jon aquino labs | personal blog

Sunday, April 03, 2011

Classes are Platonic, Interfaces are Aristotelian

I'm reading The Last Superstition and am trying to grasp the difference between Plato's and Aristotle's views of reality, and it struck me that they seem to be similar to some concepts in object-oriented programming.

  • Classes are Platonic. Plato believed that there is another dimension where universals (i.e., classes) live. In this dimension live the Tree class, the Chair class, the Dog class. In the regular world live instances of Tree, instances of Chair, and instances of Dog.
  • Interfaces are Aristotelian. Aristotle did not believe in another dimension containing universals. Rather, he believed that the universals somehow live in the objects, and that our intellects have the ability to look at objects and mentally extract the universals from them. In other words, objects have interfaces: tree objects implement the Tree interface, chair objects implement the Chair interface, dog objects implement the Dog interface.
  • Duck typing is Cartesian. Descartes subscribed to the Conceptualist view, in which universals (interfaces) don't have any kind of existence in the world – they are just in the mind.
  • No typing is Humean. This is the Nominalist view, in which there are no universals – in the world or in the mind.
Consequently, one must infer that Plato would have programmed in Smalltalk; Aristotle, in Java; Descartes, in Python; and Hume, in Basic.


Post a Comment

<< Home