So for contentious topics that have been discussed elsewhere (probably), I like to consult wikipedia. Probably asking some Large Language Model about a definition for object-oriented programming will give the same results.
The way I read the wikipedia article: Things mentioned first must be important and defining. Things further down the page less though. No guarantee that this is accurate. The first sentence (as so often with wikipedia articles) is quite good, though:
Object-Oriented Programming (OOP ) is a programming paradigm based on the concept of âobjectsâ, which can contain data and code.
I donât think itâs possible to get a grip on the meaning of OOP w/o appealing to some intuition of an âobjectâ. From what I understand, an object in OOP is meant to be an abstraction layer that helps the programmer modelling a problem. How exactly this is done, depends on the specific brand of OOP.
Your definitions:
-
I agree that the notion of objects is sold in a package with some rudimentary memory management at minimum. I contradict that this alone rules out Haskell. More then rudimentary memory management shouldnât be a violation of object-orientation per se.
-
Maybe that fits with what I called âsome intuitive notion of what is an objectâ.
-
Yes, I would want to add sub-type polymorphism to the list of defining characteristics for OOP. Just reading the wikipedia article, that isnât so clear to me anymore. E.g. what about duck-typing? But no sub-type polymorphism whatsoever would (probably) violate the intuitive notion of objects.
I would want to add to any of those definitions: OOP as a programming paradigm has been presented to me as a âbest practiceâ to follow, in the sense that I am supposed to model a given problem in terms of objects and then implement those (e.g. in the form of a class hierarchy, or just class members).
But now consider the following: In the first sentence from Wikipedia, it is stipulated that the objects contain data and code. Now having âcodeâ inside objects isnât conceptually sound (to me, that is - maybe someone can explain). By that I mean the very statement is non-sensical. In Python, the self
parameter is explicitly passed to member functions. In C++ this
is implicitly passed. But in what sense do objects contain code?
In C++, a class defines a scope and the class methods are inside that scope - OK. But having data and functions organized differently shouldnât really matter when talking about programming concepts in the abstract, I would argue. The fact that C++ has strict typing is much more important than the class scopes.
⊠that is unless you consider the history of OOP as a successor of merely âstructured programmingâ, which really is about the Where as in âWhere to put this code?â or âshould this be inside main
or should this be its own procedure`?â
So this is why I like watching the deconstruction of OOP: Itâs a wild mix of programming practices and actual concepts. Those OOP concepts exist on their own and are not enough to define OOP. And OOP is not necessary to enjoy the benefits of the concepts associated with OOP.
There just doesnât remain a lot.
OOP could be a sound abstraction layer - but it turns out, the intuitive notion of an object is just way too general. The intuitive notion of a function (the mathematical notion), is specific. This is why you can have the function-semigroup. The intuitive notion of an ADT: same. Objects, in contrast, are a dead end. When someone tells you, they built an object, you still donât know anything about what you can or canât do. In theory, there could be a canonical object hierarchy (like there is the typeclass hierarchy in Haskell) - but in practice it never came about. This is why OOP remains a ghost to me, one that we chase away.