3 ms·
It’s the lack of parametric enums (sum types) which really gets me. I use sum types constantly. Nearly as often as I use structs. For example, in typescript yo
by josephg 2mo ago
It’s the lack of parametric enums (sum types) which really gets me. I use sum types constantly. Nearly as often as I use structs.
For example, in typescript you can define a json value as something like:
type JSON = null | bool | string | number | [JSON] | {[k:string]: JSON}
Go forces me to reach for interface {}, and use a nest of dynamic dispatch code. It’s horrible. Go code is harder to write, harder to read and it runs slower as a result.
The decision is baffling. Especially given go now has generics, which are waaay more complex than enums. And sum types in go could be used to fix the constant (result | error) boilerplate. And remove nullability. Sigh.