Go Enums Suck
(www.zarl.dev)
from bugsmith@programming.dev to golang@programming.dev on 27 Feb 2024 22:04
https://programming.dev/post/10671884
from bugsmith@programming.dev to golang@programming.dev on 27 Feb 2024 22:04
https://programming.dev/post/10671884
threaded - newest
I mainly develop in C#, and I agree that having to write so much boiler plate for type safety is really boring. C# is not perfect either (it doesn’t have discriminated unions, etc.) but at least it gives type safety out of the box.
However, in general, I think enums are widely misused. I see a lot of cases where they should have been classes with a factory, but ended up being enums with a lot of static functions and switch statements.
Or having to create such abominations which is especially annoying when you find out you didn’t need one this time.
Considering when I clicked the link the result is an error about a database lock in SQLite on a blog, I’m not sure this opinion is coming from a wise and experienced developer.
A language without enums? Interesting… not the choice I would’ve made, but interesting nonetheless. Is there a reason why?
CC BY-NC-SA 4.0