News for hackers. Stuff that matters.
Re:Goenums: Type Safe Enum Generator for Go by o11c on Saturday April 26, 2025 @06:41PM (#43807871)
To be fair, enums represent a different and incompatible concept in every language I know.

It's possible to support everybody's needs in a single language, but I'm not aware of any language that has done it yet.

Re:Goenums: Type Safe Enum Generator for Go by bsaul on Saturday April 26, 2025 @06:45PM (#43807907)
"enums represent a different and incompatible concept in every language I know."

Enums has always felt very natural in every modern languages i've tried (swift and rust, for example), even with associated values. The underlying "sum type" concept also is very intuitive, and seems very complementary to structs for example.

Can you expand a bit on what you mean ?

Re:Goenums: Type Safe Enum Generator for Go by willtemperley on Saturday April 26, 2025 @08:39PM (#43808486)
This. I find Swift and Rust enums, which are indeed very similar, to be incredibly good at modelling the real world. For example the standard geospatial vector types which are heterogeneous and even recursive in the case of GeometryCollections can be modelled and operated upon very cleanly.
Re:Goenums: Type Safe Enum Generator for Go by za3faran on Saturday April 26, 2025 @09:52PM (#43808850)
Have you tried them in Java?
Re:Goenums: Type Safe Enum Generator for Go by sebazzz on Sunday April 27, 2025 @07:59AM (#43811309)
Java enums are more or less a “multiton” (as in singleton - for each value each)
Re:Goenums: Type Safe Enum Generator for Go by vips7L on Sunday April 27, 2025 @09:23AM (#43811739)
And if you want rust style enums in Java you can use sealed types.
Re:Goenums: Type Safe Enum Generator for Go by protolyticmind on Sunday April 27, 2025 @01:28AM (#43809649)
Rust has IMHO the best implementation of enums ... Mixed with match it is super powerful
Re:Goenums: Type Safe Enum Generator for Go by aldanor on Sunday April 27, 2025 @07:52AM (#43811268)
Don't forget, Rust was first implemented in Ocaml, You can guess where those best enums come from.
Re:Goenums: Type Safe Enum Generator for Go by sureglymop on Sunday April 27, 2025 @02:15PM (#43813970)
Kotlins enum classes are quite similar, probably even inspired by rust or prior ML languages. And there's `when` as an alternative to match.

Kotlins syntax is in general a bit underrated imo and I disagree that Java is up to par.