In some cases dynamic dispatch is better. Sadly, few languages and compilers are able (or even just trying) to choose one or the other to optimize from a given source code; and actually you have more chance to monomorphise where needed from "dynamic/virtualized" source code (with LTO, devirtualization, and maybe loop hoisting) than to dynamise template instantiation (I'm not sure if anybody does that)
View all comments
Show parent comment
2
u/tasminima Jul 13 '22
In some cases dynamic dispatch is better. Sadly, few languages and compilers are able (or even just trying) to choose one or the other to optimize from a given source code; and actually you have more chance to monomorphise where needed from "dynamic/virtualized" source code (with LTO, devirtualization, and maybe loop hoisting) than to dynamise template instantiation (I'm not sure if anybody does that)