News for hackers. Stuff that matters.
Re:Ask HN: Go programming language is over ten years old. Wh... by edumucelli on Sunday October 25, 2020 @01:26PM (#24888018)
I do not like it. The lack a proper (1) Class, (2) Enums (seriously, using constants to describe a proper Enum like Java has is a must, we are in 2020 not in 1980), (3) being able to call methods on methods on nil pointers, (4) generics that are available for langauge internals but not for language users, the list could go on. All this just because I am working on it few months now. Let's see how it will evolve through the years, but could not have been worst start.
Re:Ask HN: Go programming language is over ten years old. Wh... by baby on Monday October 26, 2020 @02:06AM (#24893222)
The lack of classes and generics is probably the strongest argument of Golang, so can’t agree with you there. As for enums, I miss them too. Sum types as well.
Re:Ask HN: Go programming language is over ten years old. Wh... by lanstin on Sunday October 25, 2020 @03:10PM (#24888992)
I think most Go people will put most anything that goes over the wire into some protocol description language like protobuf or even swagger. Inside your call stack I am not sure you need enums instead of constants. If you are either persisting or transmitting data then you want some formal description which will essentially get you enums as useful symbolic values.
Re:Ask HN: Go programming language is over ten years old. Wh... by cy_hauser on Sunday October 25, 2020 @05:28PM (#24890045)
Lack of real enums is one of my biggest annoyances with Go. So so many times I've put the wrong enum value in because it's just an int and it matches another set of enums. I've taken to putting each set of enums into a separate file and separate folder just to help the compiler catch this. The project I'm working on now has about 25 separate enum files+folders. Gagh!
Re:Ask HN: Go programming language is over ten years old. Wh... by TopInvestor on Sunday October 25, 2020 @08:21PM (#24891475)
I made this playground: https://play.golang.org/p/S1Yh0Oq24q-

There are a ways to do unique enums with implicit repetition. Like this: I 0 1 2 II 101 102 103 III 201 202 203 IV 10 20 40 80

Re:Ask HN: Go programming language is over ten years old. Wh... by cy_hauser on Monday October 26, 2020 @08:38AM (#24895461)
Yes and no. Most of the time my enums are well defined: ContactStatus, AwardLevel, JugeStatus, for example. I have not control over the names or values and all have a "Revoked" value. When they come in from an external system it's pretty easy to parse them and convert them to the wrong type if someone isn't paying close attention. Then they don't get caught for a week or so because the code compiles, runs, and appears to work correctly except for these occasional odd results.
Re:Ask HN: Go programming language is over ten years old. Wh... by doktorhladnjak on Sunday October 25, 2020 @09:36PM (#24891976)
Typedefing with iota should let the complier catch this, but it is an extra wonky step