Search code examples
c#c++adadynamic-bindinglate-static-binding

Why do some languages prefer static method binding rather than dynamic?


Why is the default decision in C++, C#, and Ada 95 to use static method binding, rather than dynamic method binding.?

Is the gain in implementation speed worth the loss in abstraction and re-usability?


Solution

  • In general, you can consider that you have todesign the base class for extensibility. If a member function (to use the C++ vocabulary) isn't designed to be overridden, there is a good chance than overriding it will in practice not be possible and for sure it won't it be possible without knowledge of what the class designer think is implementation details and will change without giving you prior notice.

    Some additional considerations for two languages (I don't know C# enough to write about it):

    • Ada 95 would have had compatibility issues with Ada 83 if the choice was different. And considering the whole object model of Ada 95, doing it differently would have make no sense (but you can consider that compatibility was a factor in the choice of the object model).

    • For C++, performance was certainly a factor. The you don't pay for what you don't use principle and the possibility to use C++ just as a better C was quite instrumental in its success.