A Perspective on D from game industry

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 18 09:58:15 PDT 2014


On Wednesday, 18 June 2014 at 07:58:57 UTC, c0de517e wrote:
> People think that implementing interfaces is for some reason 
> inherently slower than templates, the same they believe 
> function pointers are slower than functors. It's FALSE. The 
> ONLY reason why templates and functors can be faster is because 
> they are always inline, the compiler knows exactly what to call 
> without indirections. But that's only WORSE than the "indirect" 
> alternatives, because interfaces and pointers afford you the 
> option not to resolve everything statically, but if you want 
> you can always inline everything (put the implementation in 
> headers) and the compiler will perfectly know that it can 
> directly call a given function without overhead...

I don't think it is that simple. What you speak about is only 
possible if compiler known full source code of all application 
including all possible dynamically loaded libraries. For compiled 
languages that puts such optimization out of practical 
consideration.


More information about the Digitalmars-d mailing list