3 ms·
From the article: > Monomorphization is a total win for systems programming languages: it is, essentially, the only form of polymorphism that has zero runtime
by wtetzner 5y ago
From the article:
> Monomorphization is a total win for systems programming languages: it is, essentially, the only form of polymorphism that has zero runtime overhead, and often it has negative performance overhead. It makes generic code faster.
The point is that the way Go implements generics is in such a way that it can make your code slower, even though there is a well-known way that will not make your code slower (at the cost of compile times).
- ramesh31 5y ago>even though there is a well-known way that will not make your code slower (at the cost of compile times). That's the point though. The Golang team was surely aware of both approaches, and chose what they did as a conscious design decision to prefer faster compile times. People love Go because of the iteration speed compared to C++. And these little things start to add up if you don't have a clear product vision about what your language is meant for.
- wtetzner 5y agoOf course, I understand that they made that decision. I was just replying to this: > of cause generics can make your code slower, what did people expect. It's not unreasonable that some people might have expected monomorphization.
- erik_seaberg 5y agoIn fact I sort of thought they had announced monomorphization, though I wasn’t following really carefully.