5 ms·
This is pretty good for starters! It makes it clear that you're not interested in a real discussion. Requiring that people read The Art of the Metaobject Protoc
by tom_mellior 6y ago
This is pretty good for starters! It makes it clear that you're not interested in a real discussion. Requiring that people read The Art of the Metaobject Protocol before you'll engage with their arguments on whether C++ programmers write OOP code is clearly just evasion on your part.
This isn't knocking the book, I've read it and agree that it's edifying. This list is a good resource on OOP in general. It's just not helpful in the context of this thread.
- pjmlp 6y ago> If you have knowledge, share it, or at least share concrete references to concrete resources where one might learn what you think should be learned. Your own words, documentation and knowledge was shared, apparently you are the one not interested.
- tom_mellior 6y agoYou missed the "concrete" part. Which of these sources, concretely, should one read to evaluate the claim that "Modern C++ generally doesn’t use OOP all that much anyways.", which is what you seemed to criticise in this subthread? Again: Does one really, concretely, have to read The Art of the Metaobject Protocol, a book about Lisp, to evaluate this claim about C++? Having read the book, I would say no. Which is why I say that you are evading a real discussion. (And for that matter, it would be interesting if you fleshed out your counter-claim -- "Other than the classes used to implement all those STL concepts." -- in a bit more detail. Are you saying that all uses of C++ classes are OOP? Or that only certain uses are, but that the way classes are used to implement the STL fall into this category? Will I find the answer to these concrete questions in The Art of the Metaobject Protocol?)
- pjmlp 6y ago> Are you saying that all uses of C++ classes are OOP? Definitely, any use of class constructs with data members and member functions is OOP. Any use of data members inside class constructs represents aggregation and if any member function on a data member happens to be called, as means to help a member function to do their work, that is delegation. Any template implemented as class that uses its type parameters to decide at compile time what gets called, makes use of dynamic dispatch decided at compile time. If you prefer we can pick any random STL type and dissect all their uses of OOP features, lets start with something like std::set?
- ncmncm 6y ago> Definitely, any use of class constructs with data members and member functions is OOP. Definitely not. OOP requires, also, runtime binding and polymorphism. You can get the polymorphism by inheritance, delegation, or what-have-you. You can get runtime binding with a vtable or a name lookup. The usual term for just-encapsulation is "object-based". The STL is definitively not object-oriented, according to its author, Stepanov, who has said that giving the STL classes member functions was a mistake. OOP is a niche technique. It has uses, sometimes. More often, a function pointer suffices.
- pjmlp 6y agoNo it doesn't, hence why I mentioned that one should learn what OOP is all about. Object based languages are part of the OOP universe from CS point of view, plenty of literature, that apparently is too much to ask to read about, some of which I have provided above. So here we go about std::set and it being OOP. 1 - class set, a means for encapsulation, with most of its members de 2 - Uses delegation for memory allocation via the allocator_type 3 - Uses delegation for key lookups and value comparisasion 4 - Implements the concepts Container, AllocatorAwareContainer, AssociativeContainer, ReversibleContainer alongside their respective concept dependencies, which in OOP speak are protocols/traits/categories; 5 - The actual types used for comparisaion and allocation are instances of the respective protocols, with dispatch being decided at compilation time of std::set uses, given the respective implementations as type parameters, in a way similar to multi-method-dispatch. As bonus here is a simplified UML diagram. It isn't more detailed, because my patience to draw ASCII art is limited. ------------------------------------------------------------------------------------------- |std| | ----- | | __________________ | | | <<protocol>> | | | | Container | | | |-----------------| | | |-----------------| | | |-----------------| | | | constructor | | | | copy-constructor| | | | destructor | | | | begin() | | | | end() | | | | cbegin() | | | | cend() | | | | swap() | | | | size() | | | | max_size() | | | | empty() | | | ------------------- | | /\ | | -- | | | extends | | | | | ______________ _______________________ _______________________ | | | <<protocol>>| | <<protocol>> | | <<protocol>> | | | | Allocator | | ReversibleContainer | | AssociativeContainer | | | |-------------| |----------------------| |----------------------| | | |-------------| |----------------------| |----------------------| | | | constructor | | rbegin() | | key_comp() | | | | destructor | | rend() | | value_comp() | | | | allocate | | crbegin() | |----------------------| | | | deallocate | | crend() | /\ | | | max_size | |----------------------- -- | | | construct | /\ | | | | destroy | -- implements | | | --------------- | | | | /\ | | | | -- | implements / | | | \ / | | | implements \ / | | | \ / | | | \------------------ | | | | | | | | | | | ------------------ | | ---------------- | <<protocol>> | | | | allocator<T> | uses | set | | | |---------------|<------------------------/\|------------------| | | |---------------| \/| constructor | | | | destructor | | | | begin() | | | | end() | | | | cbegin() | | | | cend() | | | | rbegin() | | | | rend() | | | | crbegin() | | | | crend() | | | | operator= | | | | get_allocator() | | | | empty() | | | | size() | | | | max_size() | | | | clear() | | | | insert() | | | | emplace() | | | | emplace_hint() | | | | erase() | | | | swap() | | | | extract() | | | | merge() | | | | count() | | | | find() | | | | contains() | | | | equal_range() | | | | lower_bound() | | | | upper_bound() | | | | key_comp() | | | | value_comp() | | | ------------------ | |-----------------------------------------------------------------------------------------|