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

I think in many cases you don't need generics because you can use the interface mechanism instead. The way Go does it is a bit confusing at first, so I suspect many Go newcomers don't really understand they could have used it.

As an example look into the way sorting is implemented in the standard library: http://golang.org/pkg/sort/

I had to look at this example for a long time to get it... And now I have forgotten it again since it was months ago :-(

I still thought it requires too many lines to sort stuff, but it is doable.



That's effectively subtype polymorphism, while generics are parametric polymorphism. Many languages (including Java) make use of both.




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

Search: