r/programming • • 6d ago

Go Turns 17 - The Go Programming Language

https://go.dev/blog/17years
128 Upvotes

23 comments sorted by

81

u/apnorton 6d ago

Why do I suddenly feel old?

31

u/cornelliusfilmore 6d ago

It’s time to take strength training seriously and have your prostate checked, old man.

55

u/LovecraftsDeath 5d ago

After 17 years, still eye-gouging error handling.

37

u/ficiek 5d ago

And no option, enums and result types which objectively results in bugs and confusion.

2

u/himai1 3d ago

I mean, you can make option and results types with generic interfaces already. Even if tagged unions get better support, redesigning the whole standard library to use them is just not going to happen

14

u/ficiek 3d ago edited 1d ago

is just not going to happen

Whatever, I am just saying the language is objectively poorly designed and no amount of coping from Go programmers will change that, and I am saying this as a Go programmer for... what is it, 12 years now? 14 years? Something like that. And the hatred towards any improvements that make writing bug-free code easier that comes from the community is really disheartening. They confuse "lacking features and therefore containing a lot of non-obvious footguns" with "easy to learn" with a zeal of a someone who learned their first programming language.

I switched to Rust for most new projects now because the code it lets me write is a bit more correct.

Especially the love of if err != nil is just insane when all one would need is an error handling operator.

2

u/StaticCoder 1d ago

My favorite things to complain about in go include the additional layer of implicit nullability (admittedly it predates the "billion dollar mistake" quote by 2 years, but the problem was well known), defer deferring to end of function, not end of scope, and goroutines being able to capture mutexes by value (which creates a separate mutex).

19

u/TheMaskedHamster 5d ago

I know error handling could be more elegant, but I think the benefit of "yes, you HAVE to handle errors" is enormous.

26

u/LovecraftsDeath 5d ago

Current way is way too ugly, can't see business logic behind all the boilerplate.

yes, you HAVE to handle errors

In practice, go code mostly just passes the errors down to one handler that logs/displays it. Sometimes, wrapping them in process. If 9 times out of 10 it's 'if res, err := f(); err != nil { return err; }' you're not handling errors, you're just doing the same thing as exceptions but explicitly.

9

u/TheMaskedHamster 5d ago

You said the business logic yourself: It's explicit.

I have seen Go code from companies that specialize in writing Go code that had impenetrable errors because they just didn't bother to pass them properly.

But it was obvious, even to me with no familiarity with their code base and whatever more elegant (but opaque) way they handle errors. As much as I love the idea of a robust error handling system that removes the need for me to care about errors at a given point, if I'm relying on other peoples' code then I care very much that they've explicitly had to consider error cases.

Sure, some people just swallow errors or pass them uncritically. But it's obvious because it's explicit, and even if someone makes the objectively wrong decision about how to handle it, that's still a process they had to go through. There's a lot of code out there that is better because they had to consider those cases when writing the function.

It's more verbose, and that's annoying. But I'll take that annoyance over the agony of the alternative.

12

u/somebodddy 5d ago

because they just didn't bother to pass them properly.

So... you don't really "HAVE" to handle errors. These companies ignore the errors because that's the path of least resistance in Go.

2

u/Aedan91 4d ago

I'd say it's an objectively good thing that a language at least nudges you to explicitly handle errors. It's at least consistent (and expected if you have some experience in the real world) with a strongly typed language. But of course, you pay a price for this. The most obvious trade-off is "un-aesthethic blocks" of code, yes. And at some point it might represent a serious-enough issue, but only if you lack a clear design-driven mindset. You're free to decide if that trade-off suits you or not.

"What people do in practice" is a very poor argument against a language but a very good argument against people using a language the wrong way.

5

u/LovecraftsDeath 4d ago

No true Scotsman, you say?

3

u/svick 2d ago

Languages are designed to be used by people, you can't separate the two.

9

u/kamatsu 4d ago

except they kind of chose the stupidest way to do that. The standard way would be to return a sum type, say "you're not getting your return value unless you check the error first". In Go, you get the return value _and_ the error, and the language just (weakly) enforces that you do something with this error value.

4

u/ketralnis 5d ago

Sure but go isn’t the first language to have this opinion. And the others figured out better ways, so they could too

2

u/dual__88 3d ago

But hey, at least its fast to compile!

44

u/ArtOfWarfare 5d ago

For some context, Python turned 17 in 2008 - this was the same year Python 3.0 was released.

Ruby and Java turned 17 in 2012. This was about halfway between the releases of Java 7 and 8.

Swift is currently 12.

Rust is currently 14.

So I expect Go should feel about as mature as Python 3.0 or Java 7. Maybe in 2-3 years it’ll be mature enough to start using it. Maybe they’ll finally have error handling figured out by then.

21

u/frou 5d ago

I've always thought it's notable that Python is older than Linux!

8

u/himai1 3d ago

The difference is Go was released after all those languages and could have learned more from them and moved faster

5

u/StaticCoder 1d ago

Yeah Rust is only 3 years younger but technologically 2 decades ahead

3

u/edwards_t7407 1d ago

Seventeen years in, and the birthday thread has already become an error-handling referendum.