this post was submitted on 21 Aug 2023
15 points (94.1% liked)

Golang

313 readers
8 users here now

This is a community dedicated to the go programming language.

Useful Links:

Rules:

founded 1 year ago
MODERATORS
 

Not a hard question. It’s sum types! (Or enums, tagged unions, or whatever you want to call them).

top 4 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 1 year ago* (last edited 1 year ago) (1 children)

While you're at it, with sum types, you can replace this stupid nil with an optional type. Also, you can replace the stupid error handling with an either/result type. Then you can add a keyword to return early if it's left/err. Then you have Swift or Rust.

[–] vasametropolis 1 points 1 year ago* (last edited 1 year ago)

To be fair, there's huge demand for a Swift-like language in the space Go operates, since nobody will ever adopt Swift outside of Apple use cases. Rust is excellent, but garbage collection is not awful at all for most Go use cases. I think Go designers made a mistake by not introducing sum types sooner since there are many ergonomic issues that could be solved with them.

This may lead people to argue for JVM-based languages, but Go seems like a leaner and nicer package overall and compiling to static binaries so simply is still a major winning feature. That and I think Go still has performance advantages over JVM and C#.

In many ways I think Swift is better than Go as a language, but we effectively will never have that as an option people freely choose to use so it would be nice for Go to close some ground where it can and where it makes sense to do so. Go is what people already want to use as a starting point, so it makes sense for it to try and modernize a tad.

[–] [email protected] 4 points 1 year ago* (last edited 1 year ago)

Go was my favorite mainstream language for GSD for years last decade. I was happy using it.

I came off a development ‘extended holiday’ by jumping into Rust dev over the last few months. I think I’m less happy. Though my software is arguably functionally better, even if I fucking despise the way it looks and reads.

Maybe I just never realized I'm a grug brained developer at heart.

[–] [email protected] 1 points 1 year ago

I do hate the way enums are in Go. It's just barely better than using a string or int in most cases.