Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's more than just feeling pain when writing code. Using interface{} has a runtime cost. Both because of the vtable and because it requires heap-allocating something that could otherwise be inline.


Yes, that's true. The "pain" I had in mind wasn't in using `interface{}`, but in writing non-generic code. This doesn't result in a performance loss, but will result in some code duplication. (Or alternatively, extra complexity from using some sort of code generator.)

But, to be fair, in the Go world, both mechanisms are used. It depends on which costs are important.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: