3 ms·
Yeah you're right, nobody ever said to me "use interfaces because the code it's faster". On the other hand, when I studied dynamic dispatch and stuff like that
by zaphodias 4y ago
Yeah you're right, nobody ever said to me "use interfaces because the code it's faster".
On the other hand, when I studied dynamic dispatch and stuff like that, I don't think enough people told me "when you do that, you are making this tradeoff".
I feel like it's worth sharing this kind of knowledge in order to make better informed decisions (possibly based on numbers). There's no need to become an extremist in either direction.
- jesstaa 4y agoThe trade off has changed over time as memory access has become a bigger and bigger bottleneck. But caring about this is still "premature optimisation". The claim of 20x program performance difference is overblown. Compilers can often remove virtual function calls, JITs can also do it at runtime. Virtual function calls in a tight loop are slow but most of your program isn't in a tight loop and few programs have compute as a bottleneck. Measure your program, find the tight loops in your program and optimise that small part of your program.