1.4 KiB
Object Oriented Programming
Also known by its acronym OOP (POO in Spanish for Programación Orientada a Objetos) is a programming paradigm.
OOP is split between two "schools" of design: Simula-style OOP and Smalltalk-style OOP.
TODO
Simula-style OOP
Most popular languages that have OOP have it in the Simula form, so when the term OOP is used, one always means this kind of OOP. Some of these languages are:
- C++
- Java
- JavaScript
- Python
- ...
Smalltalk-style OOP (message passing)
In Smalltalk-style OOP, objects communicate with each other by means of message passing. This allows for greater dynamism. Unlike in Simula-style OOP, objects can receive any message and its up to the object whether to reply or raise an error if it doesn't understand the message.
For example, in Smalltalk if I have an object x
, I can send messages to it and it will reply
with an answer:
| x |
x := 39.
"Are you `nil`?"
x isNil. "==> false"
"Messages can carry a payload of course:"
"Are you a number?"
x isKindOf: Number. "==> true"
Some languages based on or inspired by Smalltalk-style OOP are:
- Objective-C: some C-Smalltalk chimera; similar to C++ but using message passing instead of method calling.
- Common Lisp's CLOS
- Python: but more like in a conceptual way, as in making everything an object.
- ...