logoalt Hacker News

drivebyhootingtoday at 5:42 PM1 replyview on HN

The biggest issue with stenciling is lack of inlining. So for example if the argument to a generic function is an array backed container, then element access will have to go through a method call that cannot be inlined.

Besides the call indirection, the compiler also loses optimization opportunities.

With the stenciling design many generic functions found in the C++ stl have to pay significant abstraction costs.

Anyway, I like the go design.


Replies

nasretdinovtoday at 6:31 PM

That is true. Moreover, in general the performance of generic code in Go isn't any better than interface-driven one. Generics are there in Go just for better type safety, and IMO that's sufficient already :)

show 1 reply