4 ms·
Performance is only one side of it. The bigger reason is http://stackoverflow.com/a/814939 http://stackoverflow.com/a/814939
by wfunction 12y ago
Performance is only one side of it. The bigger reason is http://stackoverflow.com/a/814939 http://stackoverflow.com/a/814939
- zak_mc_kracken 12y agoOver 20+ years of development, I've found this objection to be vastly theoretical and with no practical consequences. In practice, most classes are designed without inheritance in mind and yet, being able to extend and override them has proven infinitely more valuable than the occasional case where such an overriding breaks the parent class. The practical reality is that even if a class is not designed for inheritance, inheriting from it is unlikely to break it but very likely to make its user's life much, much easier.
- wfunction 12y agoSeemingly off-topic, but I'm curious -- what language has the majority of your 20+ years of development been in?
- zak_mc_kracken 12y agoProfessionally, Java for most of the time. Recreationally, Scala and Haskell. I did about 5 years of C++ overlapping with Java before that.
- wfunction 12y agoOk, that explains it. When you're used to Java it's easy to expect inheritance to be a big deal. The fact of the matter is that run-time polymorphism (aka virtual) is much more rarely necessary in the C++ world than the Java world. The only reason it's common in Java is that it's the only tool available for many job that C++ has other tools for, and it also avoids an extra composition overhead that doesn't exist in C++. tl;dr: Just because it's "infinitely more valuable" in Java doesn't mean the same for C++.