4 ms·
There are two possible extremes for the implementation of generics: full monomorphization on one side, and dictionaries on the other side. Both have serious dra
by mseepgood 4y ago
There are two possible extremes for the implementation of generics: full monomorphization on one side, and dictionaries on the other side. Both have serious drawbacks: monomorphization is faster, but produces bloat, and dictionaries are slower but don't produce bloat. Go chose to combine the two for a middle ground. It's a bit more complicated to implement than just monomorphization or just dictionaries, but it provides a nice balance.
- fsdjkflsjfsoij 4y agoI agree with everything you wrote but would add that it's even more complicated because there are cases, albeit rare in my experience, where full monomorphization produces slower code due to cache misses. I believe std::format in C++ is generally considered an example of this https://youtu.be/zssTF1uhxtM?t=2021 https://youtu.be/zssTF1uhxtM?t=2021