39 ms·
I don't think many languages other than rust and c++ use monomorphization extremely heavily. Pretty much everything in rust is going to be using traits and c++
by chlorion 3y ago
I don't think many languages other than rust and c++ use monomorphization extremely heavily.
Pretty much everything in rust is going to be using traits and c++ uses templates for most things as well.
Every time you use a trait or a template, the code is expanded for the specific instance, and this gives a lot of opportunity for inlining stuff.
A lot of other languages would not have the same opportunity to inline code when doing polymorphism stuff because they rely on dynamic dispatch or something similar that can't be inlined very well or at all.
So I'm not disagreeing with you at all but I think rust and c++ get to inline stuff a little more aggressively, but this is just my theory and may be incorrect!