r/ProgrammerHumor • • Oct 17 '26

instanceof Trend thatsAFunnyThingThatHappenedOnce

Post image
4.6k Upvotes

524 comments sorted by

View all comments

Show parent comment

7

u/Thesaurius Oct 18 '26

Does Go have sum types now? Last time I checked it returned a record and you had to check yourself.

2

u/Mindgapator Oct 18 '26

No indeed, but the paradigm is the same right? Return the error, and deal with it (or forward it) without a try catch. I must say Rust is nicer in that regard but it doesn't change things too much? I don't have enough xp with Rust so might be underestimating it though

12

u/Thesaurius Oct 18 '26

In my opinion, the Go approach is closer to C's error codes, as nothing stops you from using an error value and introducing a bug. In Rust, you always have to check. If you forget, the compiler will complain. It will even warn you if you use the function only for its side effect don't even use the return value.

1

u/samanzaman Oct 18 '26

No go errors are weirdly typed. Proper sum types is kore than just results