6 ms·
Why do you consider inheritance definitional? Is it definitional by de facto, or is there an authoritative definition that you are using? The reason OO is a p
by cout 5y ago
Why do you consider inheritance definitional? Is it definitional by de facto, or is there an authoritative definition that you are using?
The reason OO is a powerful organizational too is because it mirrors how many people naturally think about the real world. But inheritance as adopted by most simula-derived languages does not exist in the real world. What does exist in the real world is prototypal inheritance (specifically through cloning, not through sharing a reference to the prototype object as we see in many Self-derived languages). We see it all over biology, manufacturing, even cooking. Is a language in which cloning a structure is the primary way of achieving inheritance still OO?
- zozbot234 5y agoInheritance is definitional of OO as opposed to a simpler "object-based" paradigm.
- lolinder 5y agoDo you have a citation for "object-based" as a separate paradigm? The oldest reference I can find to that term is in the C2 Wiki, where it describes not a paradigm, but a pattern for approximating OO (including inheritance) in a procedural language without OO features[0]: > Programming using [abstract data types] is also known as object-based programming. Even though ADTs do not directly support inheritance and polymorphism, these concepts can be layered on top of a ADT implementation with some minor effort. In other words all important OOP concepts can be implemented in OBP. [0] https://wiki.c2.com/?WhyObjectBasedProgramming https://wiki.c2.com/?WhyObjectBasedProgramming
- ncmncm 5y agoDahl and Nygaard originated and developed the concept. Inheritance was in their definition. You can invent other formalisms, but those should have different names if you are not actively seeking to confuse people.
- lolinder 5y agoWhere do we see prototypal inheritance in nature? I can think of lots of examples of composition, but none of prototypes. The closest I can think of would be DNA, but even that would be better modeled as composition in my mind.
- aaron-santos 5y agoI see prototypal inheritance in communication. When I communicate that I fried an egg you automatically make a number of assumptions about the properties of that event. If we generally hold the same assumptions then I've transmitted the concept with high fidelity. However, if I believe that your assumptions about the event won't reify the event in a way that mirrors my own then I will want to override your assumption by communicating extra properties about the event. You can dive a bit into this by way of semantics. For example, the semantic frame 'cooking'[1] lists 'fry' as a member. What are the salient differences between the parent frame 'cooking' and its member 'fry'? A quick way to explore this is by examining the propositional differences between the frame and member roles. You can imagine the differences between the Instrument and Result roles and how their assumptions differ. How does this relate back to programming? One way to examine programming languages is through their ontological semantics. As much as we write programs for computers, we also write them for other people. Prototypical inheritance mirrors the structure of languages we already find in nature. [1] https://verbs.colorado.edu/verb-index/vn3.3/vn/cooking-45.3.php#cooking-45.3 https://verbs.colorado.edu/verb-index/vn3.3/vn/cooking-45.3....
- cout 5y agoMitosis is the cellular equivalent of prototypal inheritance; the cell clones itself, and then you have two cells, each a copy of the original. You even get an inheritance hierarchy when pluripotent cells divide and become differentiated; the new cell gains functionality missing from the original as genes are turned on. And yes, there's lots of composition too -- a cell is composed of cytoplasm, organelles, and a membrane (which serves as an interface to the message bus, your blood). The mechanism by which the cells are copied does involve DNA, but it and the proteins involved are an implementation detail.
- 5y ago
- zepto 5y ago> is because it mirrors how many people naturally think about the real world I’ve seen this said, but never justified. Is there anything that supports it?
- teknopaul 5y agoInteresting question. Objects with functions that they perform seems to be a construct post technology. It's a good fit for a microwave but not for a door. It's a good fit for a person or anything with intelligence but arguably OO is _not_ a good fit for an object.
- kaba0 5y agoWhat about the weather, ant colony (which only has intelligence as an emergent feature at most), fire, a forest, etc?
- cout 5y agoTo clarify, I don't think OO is natural for all problems, and I don't think it is natural for all people either. But for many people, it is natural. Do you describe the world around you using nouns? Anything you can name is an object. When you hear me use the word "pencil" you know I am describing something that's used for writing on paper, containing a substance like graphite that is probably erasable, and maybe even has its own little eraser on the end. Naming the object allows us to communicate and reason about it together; the ability to name and classify objects is the most essential element of OO (imagine a language where you can create classes but not name them; would it still be OO? I would argue it is not). Of course this is not the only way to model the world. Maybe to you the act of writing or drawing is more important; the pencil or pen or marker is secondary. Or maybe the connections between objects is important to you. Or perhaps it is not the objects that are important (i.e. those things which are acted upon) but the subjects (those things which act). Whatever model feels most natural to you is probably valid. As the saying goes, "all models are wrong but some are useful"; this applies to the OO model as much as any other.
- mercer 5y ago> The reason OO is a powerful organizational too is because it mirrors how many people naturally think about the real world. I've never found myself thinking that my pan fries an egg. I fry an egg and use the pan and the stove to do it. I've also not found myself thinking that my pan hits an intruder and dents itself. I hit the intruder (well, if I had the courage) and the resulting 'data/object' now has 'dent' as a property. The idea that my coffee machine is making coffee, or that my combo-oven is making my food is perhaps a bit more palatable, but even then it's now how I think about things. I am the one making coffee, or heating up food, and the actions needed are not inherently part of the object. IMO, the problem is that people do NOT think about the world in terms of objects, at least not in a way that conforms to what is generally considered OOP. Rather, when we think of 'objects' we generally think of data structures that we then operate on. The idea that there are objects that contain both properties/state and behavior is pretty weird irl.
- acdha 5y agoOn the other hand, when you make coffee you probably aren’t thinking about how to heat the water, measure the temperature, adjust the flow rate, etc. When you use the microwave you don’t think about cycling the magnetron to hit the power level appropriate for the settings or spin the turntable. When you drive a car, you accelerate, brake, steer, etc. without directly manipulating all of the parts & microcontrollers which respond to those control changes. You just call coffeemaker.brew(), oven.defrost(“meat”, “500g”), or car.accelerate(). From that perspective the OOP model works pretty well.
- ratww 5y agoAbstraction is good, but it's not a feature specific of OOP, though. From the perspective of Procedural Programming this also works well: brew(coffeemaker), defrost(oven, "meat", "500g"), accelerate(car). Same for FP: brewed(grains), defrosted(meat, time), withAcceleration(car).
- acdha 5y agoNobody was claiming that it was unique - if you reread the thread, I was just pointing out that the dismissal of OOP not fitting the way people thinking about the world wasn’t necessarily approaching it correctly.