News for hackers. Stuff that matters.
Re:Case against OOP is understated, not overstated (2020) by ummonk on Thursday February 10, 2022 @08:45PM (#30295729)
> This sort of begs the question: where does classical OOP, the one taught to all undergrad CS majors in programs that use Java or C++, really fit in nowadays?

As everyone is telling you, it’s a poor paradigm that makes the developer’s job harder compared to both non-OOP approaches and better approaches (mixins / multiple inheritance).

That said, one should be cognizant of the reason it was created in the first place - single inheritance allows C++ to implement fast polymorphism via virtual function tables.

Re:Case against OOP is understated, not overstated (2020) by branko_d on Friday February 11, 2022 @04:19PM (#30307115)
> single inheritance allows C++ to implement fast polymorphism via virtual function

Multiple inheritance can be implemented to be as fast as single inheritance regarding virtual function calls, and typically is in C++ by keeping multiple virtual table pointers per object. The problem this brings is that we can have pointers/references to the different parts of the same same object. A Child* may point to the start of the object, but Parent* may point to somewhere in the middle (because that's where the parent's vtable pointer happens to be). This also means that casting a pointer can change it. This can introduce some "interesting" bugs, as you can imagine.

OTOH, there are languages like C# that don't do that, but require 2 "hops" when calling an interface method, causing a slight performance penalty (a class can inherit from at most one other class, but can implement multiple interfaces). But a reference to an object always points to the object's start, which is very important for garbage collector.

Re:Case against OOP is understated, not overstated (2020) by c-cube on Thursday February 10, 2022 @10:32PM (#30296560)
C++ supports multiple inheritance though. And it still does it with (multiple) vtables. Did you mean single dispatch?
Re:Case against OOP is understated, not overstated (2020) by ummonk on Thursday February 10, 2022 @11:56PM (#30297172)
No, I just had an incorrect memory / mental model of how C++ vtables work.
Re:Case against OOP is understated, not overstated (2020) by native_samples on Friday February 11, 2022 @01:28PM (#30305169)
Yes, but multiple dispatch is much slower than single dispatch.