News for hackers. Stuff that matters.
Re:Go is boring, and that’s fantastic by mytailorisrich on Thursday July 02, 2020 @09:45AM (#23712996)
Coming from C and areas where C is used, enums tend to used with values defined explicitly because they usually don't represent an abstract set but indeed specific values that have to be respected.

An example at random from a domain Go is used a lot in (networking): When you define an enum of the resources recors in DNS you want the values to match the RFC definitions as they are used in DNS packets.

With that in mind Go's approach to enums makes sense: we usually want to label explicit values, potentially of an explicit type, we don't just want an abstract semantic label.

I haven't touched Java in a long time, but as far as I recall low-level operations on fields, bitmaps, etc. were not a strong point.

Re:Go is boring, and that’s fantastic by tsimionescu on Thursday July 02, 2020 @03:13PM (#23716865)
Sure, there is value in having your enums have specific values, but even in C they at least get a bit of namespacing.

And yes, Java enums are very verbose if you want to use them for low-level operations, but that is almost entirely the fault of the rest of Java and not enums themselves specifcally.