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

I think your so question shows exactly why generics are useful. A solution where you pass a callback predicate to the iterating function would work in Go, but be much slower than one in which the predicate logic can be inlined. E.g. if your image is 1920x1200 you would need to call the function that checks if the pixel is opaque 2.3 million times. That approach works ok in Python and Ruby which do not mind being a little on the slow side, but Go is supposed to be closer to the metal so something more efficient is needed.


i don't disagree with what you're saying (and i raise the question of efficiency in the link). my point was more about the sociology of the complaints: i think most people are complaining because they're used to generics and don't have the tools/smarts to solve problems in alternative ways.

i think the general conclusion from this thread is that generics would be useful because, at the moment, if you want top performance, you need to have type unsafe code in critical loops.

that sounds quite reasonable to me...

...so maybe i am just an arrogant bastard that doesn't think much of fellow programmers. but i suspect that most people, when they complain about generics are not making that argument. they're simply complaining because it's not what they are used to.

as i say, i may be wrong. i may be a horrible man. if people want to convert/improve me i suggest they start making comments that are a bit more nuanced than "i miss generics".


You can write a C++ style pre processer to compute efficient specialized methods from a template definition. The only problem is winning community adoption over the objections of the go dev team.




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

Search: