3 ms·
> The overhead of interface{} isn't as high as people sometimes think. The cognitive overhead certainly is. Computers exist to help us do things faster and wit
by eropple 8y ago
> The overhead of interface{} isn't as high as people sometimes think.
The cognitive overhead certainly is. Computers exist to help us do things faster and with fewer mistakes. This is a prime example of using a computer to help us make more mistakes, worse.
- foldr 8y agoYes, using interface{} introduces a small chance of runtime type errors. I have not heard of any Go projects finding this to be much of a problem in practice. You can also use the type-safe wrapper pattern to avoid this if it's likely to be a problem. There is no doubt that not having generics makes some code worse than it would be with generics. But I think the problem is often overstated.