D vs C++ classes?

Bruce Carneal bcarneal at gmail.com
Mon Jun 28 23:17:36 UTC 2021


On Monday, 28 June 2021 at 21:03:21 UTC, Ola Fosheim Grøstad 
wrote:
> On Monday, 28 June 2021 at 20:35:25 UTC, solidstate1991 wrote:
>> Multiple inheritance induces a lot of headaches (added 
>> complexity, diamond inheritance, etc.), and even C++ devs try 
>> to avoid it at all costs. It rarely has any real-life use, 
>> that couldn't be solved with interfaces and mixins.
>
> That isn't the point (if it is true). And actually, C++ stdlib 
> uses it. Some C++ devs avoid virtual in general though, but 
> that is another issue.
>
> The point is that you need multiple inheritance to unify D 
> classes with C++ classes, but you don't have to use it if you 
> don' want to, so there is no cost to having it. So basically 
> only one big benefit, and no real disadvantages.

Making a new feature optional does not, of course, actually make 
it free.  The cost includes, minimally, the cost of 
implementation and maintenance over the life of the compiler(s) 
and the debugging costs incurred by programmers encountering bugs 
in the, potentially complex, new compiler code.

OTOH, if a feature addition provides a new best-practices 
capability that displaces error prone coding going forward, then 
the benefits could very well outweigh such costs over time.  I'm 
hopeful that this is true of the template free metaprogramming 
additions proposed recently.  I'm less hopeful regarding MI.














More information about the Digitalmars-d mailing list