5 ms·
I'm baffled that the Go designers for a long time basically considered generics to be harmful - but had no problems adding reflection to the language.
by xg15 5y ago
I'm baffled that the Go designers for a long time basically considered generics to be harmful - but had no problems adding reflection to the language.
- scottlawson 5y agoReflection is essential for things like code generation and introspection in go. It isn't something you can classify as wholly harmful. It is of course possible to write bad code using reflection, but not having reflection isn't the solution. https://go.dev/blog/laws-of-reflection https://go.dev/blog/laws-of-reflection
- xg15 5y agoI'm a java guy mostly, so I might be biased, but in that language, the vast majority of overengineered, arcane and plain "black magic" code was involving reflection - whereas I almost never had a problem with generics. So I'm surprised that Go considers generics more harmful than reflection.