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

You can obviously abuse C++ templates, because they are more (or less, depending on how you look at it) than simple generics. However, in what way can parametric polymorphism be misused or be a crutch for bad designs? I can't think of an example that wouldn't be horribly contrived.


Well, parametric polymorphism in the case of go would probably just be a performance optimisation over function taking interface as parameter, right ?

i usually see monsters when you combine generics with objects and inheritence, but you're right that since go also doesn't provide those...

i think when talking about generics in go we also mean struct accepting generic components. Not just functions


Sure, and I still don't really see a problem with it. Yes, it makes the compiler more complex, but I can't think of any ways it could be abused more than the existing language features. And it would make a lot of programs written in Go simpler.


Because go is very used in data plumbing code, i found that many functions can actually work fine at the byte array level, and that it leads to a better design.

It would be very tempting with proper generic support to try to have every function work with the topmost types, just because we assume it provides more type safety. I could imagine a struct representing a "User" byte array, or other atrocities.


it's a mystery, especially to anyone who has ever seen JSON handling code in Go, that they would think generics are a crutch for bad design.




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

Search: