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
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.
- Everything is an object.
- Objects communicate by sending and receiving messages (in terms of objects).
- Objects have their own memory (in terms of objects).
- Every object is an instance of a class (which must be an object).
- The class holds the shared behavior for its instances (in the form of objects in a program list).
- To eval a program list, control is passed to the first object and the remainder is treated as its message.
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.
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.
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:
- Abstraction – providing some form of classes and objects.
- Inheritance – providing the ability to build new abstractions out of existing ones.
- Run-time polymorphism – providing some form of run-time binding.
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:
- Hawking’s singularity term was shadowed by Kurzweil’s singularity. And some physicists still mad about it.
- Some cover songs are more famous than originals
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
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.
Jonathan Rees definitions
From my POV Jonathan Rees definition is just variation of Alan Kay’s.
- Theory of Objects
- What Every Programmer Should Know about Object-Oriented Design
- Object-Oriented Analysis and Design with Applications
For me this view gives some insight, but same time opens even more questions.
- On Understanding Types, Data Abstraction, and Polymorphism, 1985, Luca Cardelli, Peter Wegner
- Fundamental Concepts in Programming Languages
- Inheritance as a mechanism for code reuse. What are different types of code reuse out there: class-based, prototype-based, duck typing?
- Types vs Classes. See also: Type Theory, Types and Programming Languages, On Understanding Types
- Programming Language Theory, Syntaxation
- Definition of polymorphism.
- Definition of object.
- Late vs early binding.
To be continued…