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

That map only works with keys and values both being int32, right?


Correct. I have to duplicate much of the code for in64 keys and values, the lack of generics hurts there.


You seem to be brushing this off as a minor nuisance, when in many cases it is a showstopper.

Need it for floats, duplicate it again.

This is a solved problem -- the fact Go doesn't have the solution reflects very poorly on Go.


There are some batshit crazy "solutions" offered from Go fans, like "no biggie, just use a templating engine to generate the code for the types you want and compile it".


I actually use that solution in c (we have some reasons to avoid c++).

Of course it sucks, but at least c has the excuse of being from the 70's.


They suffer from a strange distortion field effect.


Ironically that is the solution c++ essentially uses.


Not quite, given that C++ templates do higher-level type-checking than just expanding and checking.

Also, they support higher-order kinds (a template parameterized by a template). And specialization (specifying special cases). And automatic instantiation based on the static types at the call site. Etc.


Its not like you will be creating a collections library all the time you create some program... yes generics are cool for code reuse.. but i think some people just overreact, turning it into something that will make the language unusable or that you will have to copy-and-paste just because of the lack of generics.. this is far from truth..




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

Search: