Two big schools of Object-Oriented Programming

TL;DR There is no one “canonical” definition of OOP. There are at least two of them. From my POV there are two big definitions, which deserves separate names. I named them after biggest advocates. Those two definition have some differences and some commonalities.

I was about to get into another argue on OOP on the internet. I decided to do some research on the subject. I found more than one definition of OOP. Some of the definitions are variations of the same “tune”, some are useless. On my opinion there are two main directions of thoughts in this domain, which from two schools of OOP. School as in school of thought. The same way as there were philosophical schools in ancient Greece. The same way there are two schools of OOP:

  • Alan Kay’s school or message focused
  • Bjarne Stroustrup’s school or class focused or “PolymorphismEncapsulationInheritance” in terms of c2

I must emphasize that this article is not about what is best way to do OOP, because such discussion will lead to holy war. Instead purpose of this article is to help to recognize the fact that there are two ways to think about OOP. I believe this will help to build more constructive discussions about OOP. Next time you will start discussion on OOP or OOP vs make sure you know which school of OOP you are talking about.

About names

I choose Alan Kay and Bjarne Stroustrup as founders of schools, because they are big advocates of OOP and authors of first OOP languages of each school correspondingly. I’m aware that there are arguments on which programming language is the first OOP language and who invented OOP. See history section.

Kay's school

Stroustrup's school

Advocates

Kay's school

Alan Kay one of authors of SmallTalk, Sandi Metz OOP advocate in Ruby world.

Stroustrup's school

Bjarne Stroustrup author of C++, Grady Booch author of UML

Programming Languages

Kay's school

SmallTalk, Ruby

Definition

Kay's school

  1. Everything is an object.
  2. Objects communicate by sending and receiving messages (in terms of objects).
  3. Objects have their own memory (in terms of objects).
  4. Every object is an instance of a class (which must be an object).
  5. The class holds the shared behavior for its instances (in the form of objects in a program list).
  6. To eval a program list, control is passed to the first object and the remainder is treated as its message.

The Early History Of Smalltalk

This definition is derived from early versions of SmallTalk (SmallTalk-72?), and rules 5 and 6 clearly show SmallTalk's Lisp heritage. Kay remarked as such, noting that rules 4-6 would mutate as SmallTalk developed.

Alan Kays Definition Of Object Oriented

Other note which emphasize messaging:

OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in SmallTalk and in LISP. There are possibly other systems in which this is possible, but I’m not aware of them.

The Deep Insights of Alan Kay, 2013

Stroustrup's school

Given these general criteria for a definition of "object-oriented" you can find several plausible candidates, and several communities have their own definitions. However, I suggest we stick to the traditional definition of object-oriented used within broad communities of programmers. A language or technique is object-oriented if and only if it directly supports:

  1. Abstraction – providing some form of classes and objects.
  2. Inheritance – providing the ability to build new abstractions out of existing ones.
  3. Run-time polymorphism – providing some form of run-time binding.

Bjarne Stroustrup, Why C++ is not just an Object-Oriented Programming Language

See also: What is "Object-Oriented Programming"? (1991 revised version)

What is the right definition?

This question will still arise, so I’m feel it would be right to give my opinion before holy war started.

Alan Kay invented term “object oriented”, SmallTalk appears earlier, so his definition is the “canonical”, right?

Short answer: this is wrong question to ask. Alan Kay coined the term (I do not like word “invented” in this context) and theory behind it. Stroustrup used the same term (maybe not he, maybe it was media fuss, maybe it was done unintentionally) and gave it other definition. No reason to get crazy about this. Happened millions time before:

And as of now there are a lot of people who follows one or another school. So it would make not much sense to say that some of definition is better because it was invented first or have more followers. The only reasonable thing we can do is to give them proper names and not confuse with each other.

Differences between definitions

Definitions are not completely different they just focused on different things. The same way as you ask what is difference between fruits and vegetables, answer depends on who you are asking cook or botanist.

Notes on diagram

Messages from actor model are not the same messages from Kay's OOP. But both concept share idea of communication via messages

In Kay's OOP it is possible to organize program flow without built-in if-else. In Stroustrup's OOP it is possible too, but it is not built-in feature, so most time it pairs with procedural if-else.

History of OOP

  • 1963 - Ivan Sutherland’s Sketchpad is considered a pioneering work in both object orientation and GUIs.
  • 1967 - Simula appears, and whether it or SmallTalk should be considered the first object oriented language is still a matter of debate.
  • 1969 - Dennis Ritchie starts developing C.
  • 1972 - SmallTalk appears. It’s the brainchild of Alan Kay, who coined term “object orientation”.
  • 1979 - Bjarne Stroustrup starts working on C with Classes, the precursor to C++.
  • 1983 - Objective C appears, and essentially is an effort to add SmallTalk’s flavor of object orientation to C.
  • 1985 - Object Pascal appears, and is almost immediately popularized by Turbo Pascal 5.5.
  • 1986 - Work begins on CLOS, an effort to bring object orientation to Common Lisp.
  • 1991 - Visual Basic is released.
  • 1995 - Java is released.
  • 1995 - Delphi is released.

Source: programmers.stackexchange.com

Other notes

Jonathan Rees definitions

From my POV Jonathan Rees definition is just variation of Alan Kay’s.

Books

PS

For me this view gives some insight, but same time opens even more questions.

To be continued…