4 ms·
C++ isn't like Java in this sense, it's a multi paradigm language and you can use it effectively without ever doing Java style OOP. The STL is mostly OOP free b
by mattnewport 8y ago
C++ isn't like Java in this sense, it's a multi paradigm language and you can use it effectively without ever doing Java style OOP. The STL is mostly OOP free because Alexander Stepanov recognized that it was mostly a bad idea and a lot of modern C++ doesn't use inheritance, virtual functions, abstract classes, getters and setters or a lot of the other Java style OOP junk except sometimes as an implementation detail.
- ilovecaching 8y agoI’ve never once worked in a C++ code base that didn’t make use of OO. As long as it’s available, it will be used.
- mattnewport 8y agoFor most of the C++ code I write removing inheritance and virtual functions from the language wouldn't have much impact (although a few abstractions might have to be implemented differently under the hood). The same cannot be said for Java.
- pjmlp 8y agoApparently now it is common to forget that Java style OOP junk was originally mid-90's C++. STL builds up on OOP abstractions, class templates, static method dispatch, type polymorphism, abstract classes for allocators, iostreams, base classes for data structures common methods.
- mattnewport 8y agoSTL is just the containers / iterators / algorithms part of the standard library, the part that Alexander Stepanov designed and originally implemented. Most of the less pleasant parts of the standard library like iostreams come from elsewhere. Templates, static method dispatch and type polymorphism are not really part of OOP, certainly not Java style OOP. Abstract classes for allocators are a very recent addition with polymorphic allocators and are a good example of OOP features being used in modern C++ as more of an implementation detail (a way to get dynamic dispatch / type erasure).
- pjmlp 8y agoIt is C++ OOP, regardless of how Java does it. Java is not the last word in what OOP means in practice, and is a younger language, which took many OOP ideas from C++ OOP libraries that were current when Java was designed. In fact something like J2EE was a relief versus using CORBA or DCOM/MTS, kings of OOP boilerplate. Or the surviving king of C++ GUI frameworks, Qt. As for the STL part you refer to, the original one, containers / iterators / algorithms, it makes use of C++ classes, methods, aggregation and delegation, which are definitely OOP. OOP doesn't have a rule that it is only OOP when all concepts are used in every single class.
- mattnewport 8y agoThe STL is more derived from Abstract Data Types than from OOP but there is overlap between those. Basically the good parts of OOP is ADTs and are embodied in the STL, the bad parts are most of the rest and are embodied in Java.
- pjmlp 8y agoIt is still OOP from CS point of view, regardless how you want to sell it and keep hand waving the fact that Java got it from C++. The Gang of Four book uses Smalltalk and C++ for its pattern examples, Java wasn't even invented when the first edition came out.
- mattnewport 8y agoTo bring it back to the original comment I was replying too and to the original email, Alan Kay says in the email: > OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them. He was writing in 2003 so presumably didn't / doesn't consider Java or C++ OOP languages by his definition. The comment I was originally replying to said: > C++, Java, Python, are all founded in confused interpretations of OO. OO has also become so synonymous with these implementations that we should just let the paradigm go entirely and start afresh. And I was taking issue with C++ being included with Java in this (I think Python shouldn't really be included either). C++ is a multi paradigm language and while I agree the OOP parts of it that it has in common with Java are neither very good nor what Alan Kay meant by OOP, C++ supports other better programming paradigms better than Java does. The good parts of C++ style OOP are mostly the ADT bits. The less good parts are inheritance and virtual functions. Design Patterns makes heavy use of the less good parts of that style of OOP and most of the problems it addresses are better solved in other ways that modern C++ supports quite well.