Hacker News new | past | comments | ask | show | jobs | submit login

Golang doesn’t have sum types is Golang’s biggest problem, not generics



Yup. I love Go but they didn’t get types right. The level of abstraction is too low, and embedding and iota never feel quite right.

Rust got the basics right. Pattern matching, no nulls, traits, sum types, and the sugar around try with the ?-notation is also great.

Despite it all, this is not a dealbreaker, and Go shines for striking a great balance of a sensical language. But I always cringe a little inside when fanboys defend even the most awkward and annoying aspects of Go.


> embedding [..] never feel quite right.

funnily enough, I would argue that struct embedding is one of the things that Go actually got right. It's simple and elegant, and I think it could've been a useful addition to Rust.


Yeah to be fair I don’t think I even have a problem with embedding per se. It’s quite nice. It’s more the fact that embedding can be used to work around missing type system features. I can’t recall exactly, but I remember using embedding for things that it probably wasn’t designed for, because it would save me a ton of boilerplate.


Almost every single case of embedding I've encountered was buggy in some way.

Explicit composition is much more reliable.


If someone autogenerates one way or another all the delgation, then that's just as buggy as embedding. The presence of all the explicit composition in the codebase doesn't mean that anyone actually sat down and thought about it all.


Autogenerating delegation is bad for the same reason. Having to explicitly delegate in every single case forces you to think about it.

Alternatively, it forces you to use the type system to make a better abstraction.


> forces you to think about it

forcing people to type something never forces them to think about it.


As someone that also has to wear DevOps hat, I really would like that Rust had matured first.

At least newer CNCF projects aren't going into Go as much as they previously did.


Also a reason why Golang isn't viable for DS/ML. I have 6 years of experience in Go, and I thought it would be easy to implement a PyTorch like library in a weekend, I had done so with Python and Julia previously. Go's lack of sum types is a huge restriction, once you hit this wall you realize it's the reason for a lot of wacky workaround in various libraries (especially any parsing libraries!)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: