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

Coding without generics turns out to have many advantages. Mostly code bases that need to evolve rapidly without getting locked in to abstractions that don't fit anymore. It certainly is a mindset shift, and may be better at scale, but it's also more tedious and sometimes you just want a freaking Foo<Bar>.


I don't really see that. How does coding IntList and then StringList help you evolve more freely than List<Int> and List<String>?

(Honest question ... I'm interested to hear what you have in mind.)


>Coding without generics turns out to have many advantages. Mostly code bases that need to evolve rapidly without getting locked in to abstractions that don't fit anymore.

How would Generics restrict you any more than the numerous variations on the same functions for different types (that you need today)?

Except if the alternative is using interface{} for everything, in which case, yes, Generics would be more restrictive.


Generics would make go code safer, less reliant on complicated tricks to circumvent language limitations and the need for reflection and ultimately make programs less brittle since it would reduce the amount of code needed for a task in general. The only valid argument against them is compilation speed but it hasn't been tried in real.


Even the compilation speed is not a problem related to generics themself, it's a problem related to monomorphisation.

If you keep dynamic dispatch, you pay almost no compilation penalty.




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

Search: