top | item 41137484

(no title)

jdnendjjd | 1 year ago

This argument is brought up again and again, but it is just wrong.

Go had both generics and iterators from the get go. Just not user defined ones.

Thus it is obvious that the creators of the language always saw their need for a simple and productive language

discuss

order

eweise|1 year ago

Not obvious to me. We just implemented a streaming solution using the iterator interfaces. They are just functions so reading the code its easy to understand. Adding special language support only serves to obfuscate the actual code.

valyala|1 year ago

Go provides generic types since v1.0 - maps, slices and channels. Go also provides generic functions and operators for working with these types - append, copy, clear, delete. This allows writing clear and efficient code.

There is close to zero practical need in user-defined generic types and generic functions. Go 1.18 opened Pandora box of unnecessary complexity of Go specification and Go type system because of generics. Users started writing overcomplicated generic code instead of writing simple code solving the given concrete task.

sterlind|1 year ago

tell me, how often do you find yourself writing `interface{}`?

joeblubaugh|1 year ago

I do agree with his point that the implicit mutation of the loop body for an iterative will be difficult to debug.