3 ms·
Sorry, but interfaces are not a replacement for sum types. Trying to shoehorn every situation where you might want to deal with multiple different types of thin
by woah 5y ago
Sorry, but interfaces are not a replacement for sum types. Trying to shoehorn every situation where you might want to deal with multiple different types of things into figuring out what common interface they could implement is a pretty terrible pattern (although interfaces are great where they are actually applicable). The Go solution of using reflection on empty interfaces and type switches when the interface pattern fails instead of sum types is a hack that forces you to throw away type safety.
Go <1.18 often feels like it is an half-finished language, except there are a lot of people ready to jump down your throat about how it's actually good that it is half-finished. Real "ignorance is strength" vibes. And I'm someone who writes Go every day.