Slow performance compared to C++, ideas?

Jonathan M Davis jmdavisProg at gmx.com
Fri May 31 20:08:37 PDT 2013


On Friday, May 31, 2013 23:59:45 Juan Manuel Cabo wrote:
> Making everything final by default would IMO kind of break
> automated mock classes generation for unit testing,
> automatic proxy class generation for DB entities, and
> other OOP niceities.

Then just mark them all as virtual if you don't want to have to worry about 
it.

> And it wasn't just marking methods final which got the
> D version of the raytracer in this thread faster than
> the C++ version in the end. (it was a combination of
> four or five things, which involved a bit of unrolling,
> avoiding array literals, and so on).

Far more than just a raytracer cares about whether functions are virtual, and 
no, making member functions non-virtual by default will not suddenly speed up 
code everywhere, but there _is_ a cost to having member functions virtual by 
default, and there's almost no benefit to it IMHO. And it seems to be folks who 
use D in real programs in real companies who most want functions to be non-
virtual by default. Both Don and Manu are completely on board with making 
member functions non-virtual by default and hate the fact that they're not.

- Jonathan M Davis


More information about the Digitalmars-d mailing list