3 ms·
This makes me want to find a side project for an excuse to give Go another try (I last used it professionally pre-generics). I do still wish it had discriminat
by piinbinary 2mo ago
This makes me want to find a side project for an excuse to give Go another try (I last used it professionally pre-generics).
I do still wish it had discriminated unions (algebraic data types) and some better error handling ergonomics.
- ainar-g 2mo agoRe unions: https://github.com/golang/go/issues/76920 https://github.com/golang/go/issues/76920 You might want to follow this proposal, if you aren't already. It's the most recent one, and it's supported by quite a few “core members” of the Go Team. I don't think it'll land in 1.28, but I like the fact that it's still a feature that's being actively discussed.
- Mawr 1mo agoFor a TL;DR, most relevant comment is: https://github.com/golang/go/issues/76920#issuecomment-5310309424 https://github.com/golang/go/issues/76920#issuecomment-53103...
- codegeek 2mo agoDo it. It is just a beautiful language to write and much simpler to pickup than many others. I am a fan boy of course but I love Go.
- osigurdson 2mo agoGo is extremely easy to pickup. If you know any language you probably know Go already for the most part (channels notwithstanding). I wouldn't say it is a "beautiful" language however. Though that is in the eye of the beholder, I don't think the Go designers were even really going for beauty.
- fragmede 2mo agoThey were going for readability. You can make some impossible to read code with C++ because the programmer was too clever, and the designers of golang wanted to avoid that.
- atomicnumber3 2mo agoThey were, very unfortunately, outsmarted by said too-clever programmers. As such I would like to request my enums and ternaries be returned to me. Trust me, they will not make a dent in the messes people have still managed to create.
- codegeek 2mo agoExactly. I was talking more about readability.
- Splizard 2mo agoTagged unions can be implemented in user code, you dont actually need language support to use them. https://github.com/splizard/tagged https://github.com/splizard/tagged
- mirashii 2mo agoThis is only a small piece of the story for what people say when they want tagged unions. Without all of the ancillary support in the language, like exhaustive pattern matching, it really doesn't count.
- Splizard 2mo agoYou can also add support for exhaustive switches on tags.
- catlifeonmars 2mo agoJust as a linter config though?
- Splizard 1mo agoNo, by leveraging unkeyed struct initializers as the switch case pattern, which the Go compiler does exhaustiveness checking on.
- shhsshs 2mo agoThat is a LOT of code (very ugly code, I would add) that could be replaced by `type Float = float32 | float64` in a language with actual support for union types.
- kccqzy 2mo agoTagged unions are not union types. A union type is a supertype for any arbitrary collection of types, but a tagged union aka sum type is a single type with multiple data constructors, and does not require subtyping to be implemented.
- catlifeonmars 2mo agoHaving worked a couple of greenfield go shops post generics, it’s still quite rare to find them in first party code. They’re just not that useful outside of library APIs. Proper algebraic data types would be a huge game changer.
- qwm 2mo agoI think you're gonna like it a lot more now. The language has gained a lot of nice things since they added generics