they are so pervasive/important that it should be included in the core library. I'd include my own collection_utils every single time.
That said, having a library function of course requires it to work in a type safe way for all collections/functions, which might make this argument really be one about generics and not about two collection functions. If this is omitted because generics is, I think it's just another argument why omitting generics is making the language simple to the point of being stupid.
Instead of map/filter:
// using some fake filter/map/lambda syntax
names := machines.filter(strings.HasPrefix(m.tag, "ec2")).map(|m| = m.name)
why not just write names := []string{}
for _, m := range machines {
if strings.HasPrefix(m.tag, "ec2") {
names = append(names, m.name)
}
}
What happens when you read that first implementation? Don't you read it as "for each machine, if its tag has the prefix "ec2", then append its name to the list that is returned? Isn't that the exact same thing you'd read the second one as? Except that the second one requires no special knowledge other than loops and if statements.
I can write go code that makes this line legal:
but I'd probably write code so it looked like this: Is either of these harder to read? Does it matter that parseInts is a "map" and odds is a "filter"? Their function is obvious by their names. If anything, the words "map" and "filter" are extraneous.