Re:Hacking sum types with Go generics
by skybrian on Monday March 14, 2022 @12:13PM
(#30674219)
How does this affect performance? Maybe sticking with switch statements and writing a linter of some sort to do exhaustiveness checks would be a better idea?
[ Parent
| on HN ]
Such a thing exists: https://github.com/BurntSushi/go-sumtype
I should say, we have absolutely no performance requirements, at least in terms of what this will do.
If we could add 10% developer efficiency for 20% performance hit, we'd take that in a heartbeat. The nanoseconds this construct might cost are just irrelevant to us, our customers, or our bottomline.
Obviously if you're writing some low-level performance sensitive code then this won't be free, but I expect most people are in our situation.