Enums vs Union Types

Debates on the value, design flaws, and alternatives to enums in programming languages like Go, TypeScript, C#, and others, often preferring union types or sum types for safety and usability.

➡️ Stable 0.7x Programming Languages
2,759
Comments
19
Years Active
5
Top Authors
#7333
Topic ID

Activity Over Time

2008
2
2009
3
2010
5
2011
30
2012
35
2013
130
2014
70
2015
127
2016
71
2017
131
2018
109
2019
137
2020
202
2021
260
2022
282
2023
327
2024
442
2025
368
2026
28

Keywords

pypi.org SomeEnum TypeScript SomeConstEnum IMO JS lang.org apple.com SomeEnumType Enumerations.html enums enum types sum types string union languages sum typescript int

Sample Comments

Waterluvian Mar 16, 2023 View on HN

Does anyone else find that Enum is just not worth using and you’re better off with union types?

shayarma Mar 1, 2024 View on HN

enums are handled poorly in so many language. very confusing.

marcus_holmes Dec 10, 2021 View on HN

Seconded on Enums. It's annoying that they're not there.

epolanski Aug 17, 2025 View on HN

Enums are crap and unsafe use union types.

sedatk Aug 16, 2020 View on HN

Note to the next language designer: don't use strings as a substitute for enums.

HWR_14 Jul 9, 2023 View on HN

What's wrong with enums? Enum types in general are very useful.

antihero Dec 2, 2025 View on HN

Unless you use enums, of course.

fooker Feb 18, 2023 View on HN

Isn't this partly why `enum class` was introduced, and is now the idiomatic way to express enums?

Belphemur Jan 22, 2019 View on HN

Why it make it a string enum then?You can do that in any typed language too.

motorest Jan 22, 2025 View on HN

You just posted a justification to use enums.