Slow performance compared to C++, ideas?

Steven Schveighoffer schveiguy at yahoo.com
Mon Jun 3 19:50:42 PDT 2013


On Mon, 03 Jun 2013 12:25:11 -0400, Manu <turkeyman at gmail.com> wrote:

> You won't break every single method, they already went through that
> recently when override was made a requirement.
> It will only break the base declarations, which are far less numerous.

Coming off the sidelines:

1. I think in the general case, virtual by default is fine.  In code that  
is not performance-critical, it's not a big deal to have virtual  
functions, and it's usually more useful to have them virtual.  I've  
experienced plenty of times with C++ where I had to go back and  
'virtualize' a function.  Any time you change that, you must recompile  
everything, it's not a simple change.  It's painful either way.  To me,  
this is simply a matter of preference.  I understand that it's difficult  
to go from virtual to final, but in practice, breakage happens rarely, and  
will be loud with the new override requirements.
2. I think your background may bias your opinions :)  We aren't all  
working on making lightning fast bare-metal game code.
3. It sucks to have to finalize all but N methods.  In other words, we  
need a virtual *keyword* to go back to virtual-land.  Then, one can put  
final: at the top of the class declaration, and virtualize a few methods.   
This shouldn't be allowed for final classes though.

My one real experience on this was with dcollections.  I had not declared  
anything final, and I realized I was paying a performance penalty for it.   
I then made all the classes final, and nobody complained.

-Steve


More information about the Digitalmars-d mailing list