3 ms·
I mean, yes and no. That's why this is a semantic debate. There are no right or wrong. Paradigms of programming are not formal concepts. Some people say the es
by didibus 8y ago
I mean, yes and no. That's why this is a semantic debate. There are no right or wrong. Paradigms of programming are not formal concepts.
Some people say the essence of OOP is polymorphism. Others say it is inheritance. Others say it is the tying together of data and behavior.
I personally find issue with saying OOP is just ADTs + polymorphism. Which is what rust traits, go interfaces and java interfaces are.
Type A
Type B
function F(value) {
switch(typeof value) {
case A: "I am A."
case B: "I am B."
}
}
There, I have achieved object oriented programming. I have values with an identity, A or B, and I have polymorphic functions over them.
I don't know, it feels too broad to be useful.
That's why I prefer to say that OOP is more related to the tying together of data and behavior behind an object. This is how the Gang of Four book defines OO.
I find it frames things in a way that is more differentiating.
So now I can have OO, inheritance and polymorphism in any combination I want. This means Clojure/Script can now be defined as supporting inheritance and polymorphism, which it does, yet not supporting OO. And I can have another language supporting OO and polymorphism, but not inheritance, such as Rust. Or without OO and inheritance, but with polymorphism like Go, etc.
- pjmlp 8y ago> This is how the Gang of Four book defines OO. That book defines OO from the point of view of Smalltalk and C++.