Inherent code performance advantages of D over C?

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Sat Dec 7 01:52:45 PST 2013


On 07/12/13 02:10, Walter Bright wrote:
> On 12/6/2013 4:40 PM, Manu wrote:
>> you know perfectly well that D has a severe
>> disadvantage. Unless people micro-manage final (I've never seen anyone do this
>> to date), then classes will have significantly inferior performance to C++.
>> C++ coders don't write virtual on everything. Especially not trivial accessors
>> which must be inlined.
>
> I know well that people used to C++ will likely do this. However, one can get in
> the habit of by default adding "final:" as the first line in a class definition,
> and then the compiler will tell you which ones need to be made virtual.

The disadvantage of this approach is that, if one forgets to add that "final", 
it doesn't just produce a performance hit -- it means that it may be impossible 
to correct without breaking downstream code, because users may have overridden 
class methods that weren't meant to be virtual.

By contrast, if you have final-by-default and accidentally leave the "virtual" 
keyword off a class or method, that can be fixed without hurting anyone.


More information about the Digitalmars-d mailing list