Re:Go 2 Draft Designs
by orblivion on Tuesday August 28, 2018 @01:28PM
(#17860791)
I'd say generics aren't just about avoiding copy-pasting. It's also added type safety. At this point the closest thing is using an interface as a function parameter. You get a dynamically typed value (albeit limited to types that implement the interface).
[ Parent
| on HN ]
That, and efficiency, as the generated code can be inlined in many cases.
The closest thing is auto-generating code, not using interface{}.
Re:Go 2 Draft Designs
by platinumrad on Tuesday August 28, 2018 @02:34PM
(#17861527)
Yes, but there's still a depressingly large amount of code in the wild that just casts interface{} back and forth.
Common with ORMs. The gorm API is horrible - it's all interfaces.
The only reasonable ORM library I've seen is sqlboiler, which uses code generation.