I'm just wondering. What makes OOP significantly better than traditional structured programs. I understand encapsulation, inheritance, polymorphism, etc. What I want to know if there is a lower level feature, maybe hardware level, where OOP might be better. Thanks a lot in advance!
7 Answers
I don't know that we can say "significantly better" in all cases. We don't agree on what to measure, so "better" is hard to judge. And "significantly"? Even harder.
It's also untrue that an object-oriented style is best suited to all problems.
I think object-orientation was invented because it maps well to a world that's easily modeled with objects. Partitioning a problem into software components that maintain state and behavior together makes it easier to decompose a large problem into smaller, more manageable pieces. Allowing a component to own its data makes it easier to know where changes to state are made.
But we still have procedural, functional, and declarative styles of programming.
Comments
If you don't count indirect jumps, there's nothing on the hardware level that gives OOP a low-level advantage. (But jump tables had been in use for ages before OOP became widespread.)
The main advantage of OOP is just the ease of modelling. Which also sets out the boundaries of OOP's usefulness, as some problems don't lend themselves to OO type modelling.
Comments
OOP it's not a hardware, physical issue.
It's all about of how to find better coding practices which empowers productivity, efficiency, scalability and maintainability.
In instance, it has evolved because it provides features that have shown success stories during last 20 years, starting with first not that OOP Smalltalk, C++ to Java, C#, Ruby, Python and many others.
Any other point about hardware optimization is an implementation decision by a concrete OOP programming language compiler or interpreter.
So, at the end of the day, the question should be, "is this OOP-based programming language hardware optimized in a better way than some other one that's based on structured programming?".
Comments
I don't think OOP is applicable at a low level (if I understand you correctly) as it is an abstraction (like many other software development paradigms) and it makes sense when you build your software using some higher level constructs, but not machine code, for example.
In any case, if you introduce OOP on low level (let's say allow inheritance on CPU level) that will most likely be a higher level abstraction implemented on top of the exsiting CPU commands anyway.