Hacker News new | ask | show | jobs
by fiedzia 1652 days ago
> I get generics, but they really don't come up in daily use with the tasks where I use Go.

I sort of understand this argument, but I can't really imagine defining queue as something else then <T> wait_for_item() -> T. I've been writing Python for to long to know that wait_for_item() -> any will backfire in production eventually and I don't want that. At some scale (both in code size and amount and scope of dependencies) those problems just become too serious and too common to not have language that deals with that. And Go is way too popular for people to limit its use only for the cases where it currently works.

2 comments

Define queue using generics, sure. It will be huge for people waiting packages.

A specific queue is typically well defined and has a struct in/out.

There are times when I've wanted arbitrarily nested JSON that doesn't map into structs very well, but it is uncommon enough.

I guess a better response to this is that I don't use generics a lot when writing Go, but I probably use a lot of packages where they would have been incredibly useful.