←back to thread

Constraints in Go

(bitfieldconsulting.com)
210 points gus_leonel | 1 comments | | HN request time: 0.203s | source
Show context
indulona ◴[] No.42163167[source]
i have been writing Go exclusively for 5+ years and to this day i use generics only in a dedicated library that works with arrays(slices in Go world) and provides basic functionality like pop, push, shift, reverse, filter and so on.

Other than that, generics have not really solved an actual problem for me in the real world. Nice to have, but too mush fuss about nothing relevant.

replies(10): >>42163189 #>>42163244 #>>42163415 #>>42163694 #>>42163834 #>>42164296 #>>42164983 #>>42165141 #>>42165270 #>>42165680 #
tonyedgecombe ◴[] No.42163415[source]
I sometimes wonder if they should have implemented generics. On the one hand you had a group of people using go as it was and presumably mostly happy with the lack of generics. On the other side you have people (like me) complaining about the lack of generics but who were unlikely to use the language once they were added.

It's very subjective but my gut feeling is they probably didn't expand their community much by adding generics to the language.

replies(5): >>42163502 #>>42163612 #>>42164299 #>>42169690 #>>42169802 #
sbrother ◴[] No.42164299[source]
Having recently had to work on a Go project for the first time, I think I agree with you here. I'd tried Go a little bit when it came out, had zero interest in what it offered, and then when I was asked to work on this project a couple months ago I thought it would be fun to try it out again since I had read the language had improved.

No, it still feels like programming with a blindfold on and one hand tied behind my back. I truly don't get it. I've worked with a lot of languages and paradigms, am not a zealot by any means. Other than fast compiles and easy binary distribution, I don't see any value here, and I see even experienced Go programmers constantly wasting time writing unreadable boilerplate to work around the bad language design. I know I must be missing something because some people much smarter than me like this language, but... what is it?

replies(5): >>42164896 #>>42165159 #>>42165914 #>>42167124 #>>42169013 #
indulona ◴[] No.42165914[source]
> I see even experienced Go programmers constantly wasting time writing unreadable boilerplate

if it is unreadable, in Go, probably the most readable language used today, i would question the aforementioned experience.

replies(2): >>42166542 #>>42167645 #
LinXitoW ◴[] No.42167645[source]
I don't think a language where for every 1 line of functionality, you need 3 lines of error handling boilerplate gets to be called readable.

Heck, Go went out of it's way to "subvert expectations" more than the last season of Game of Thrones.

99% of decent C-ish languages either do "String thing" or "thing: String", but Go is so fancy and quirky, it does "thing String" for no freaking reason. Don't get me started on the nightmare that is map types.

replies(1): >>42168136 #
kweingar ◴[] No.42168136[source]
I like Go's error handling. The reader knows exactly which lines of code can encounter an error, and exactly how the error is handled.

I find that exception-based code is much harder to read. The happy path is clearer, but exceptional code paths are often completely obscured. It's harder to reason about what state the program is in when the exception is handled.

replies(2): >>42168746 #>>42189956 #
1. the_gipsy ◴[] No.42168746[source]
Exceptions have been a mistake, the alternative are Result types, a concept which predates go.