Live data from Hacker News

Thirteen Years of Go

go.dev

171–180 of 217 posts

Re: Thirteen Years of Go

#171
post #146
post #128

Earlier quoted context omitted.

Error handling is strictly worse than pretty much any other language out there — you are only making you believe that you are handling your error cases. A pragmatic “handle it here or bubble it up” is a much better approach, as more often than not you can’t actually handle the error at call site. Goroutines in themselves won’t give you actually correct concurrency. I really hope that Go doesn’t replace Java.

>Error handling is strictly worse than pretty much any other language out there — you are only making you believe that you are handling your error cases. A pragmatic “handle it here or bubble it up” is a much better approach, as more often than not you can’t actually handle the error at call site. It could've definitely be better (just Rust-like Result type would make it so much clearer to handle) but Go's insistence…

> are encouraged to add context to the error message instead of "here is stack trace, fuck you user, you're not worth knowing what is wrong"

haha, so true. I almost always wrap errors at every level with addition context. If it was worth doing, then it's worth explaining.

People that prefer try/catching large sections of functionality or want to skip verbose handling of errors often have not thought through the user or tester experience. Heck, even trying to recreate the issue/state from production.

if err != nil { return err }

vs

if err != nil { return fmt.Errorf("context here: %s: %w", action_type, err) } (or wrapping some custom app error with context for the trace)

Of course you don't want to leak private details, but often there is a public component that is worth adding. This also brings up the concept of dual-error chains where what you log and what you report to the client are different.

Re: Thirteen Years of Go

#172
post #128

Earlier quoted context omitted.

Error handling is strictly worse than pretty much any other language out there — you are only making you believe that you are handling your error cases. A pragmatic “handle it here or bubble it up” is a much better approach, as more often than not you can’t actually handle the error at call site. Goroutines in themselves won’t give you actually correct concurrency. I really hope that Go doesn’t replace Java.

> A pragmatic “handle it here or bubble it up” is a much better approach This is exactly the approach used in Go code, so I'm not sure what you're referring to. If you're talking about the fact that you can technically ignore an error result like res, _ := doWork() then that's a fair point. But we still have https://staticcheck.io/docs/checks#SA4006 for that.

I don’t see any automatic bubble up with Go.

Re: Thirteen Years of Go

#173
post #146

Earlier quoted context omitted.

>Error handling is strictly worse than pretty much any other language out there — you are only making you believe that you are handling your error cases. A pragmatic “handle it here or bubble it up” is a much better approach, as more often than not you can’t actually handle the error at call site. It could've definitely be better (just Rust-like Result type would make it so much clearer to handle) but Go's insistence…

> are encouraged to add context to the error message instead of "here is stack trace, fuck you user, you're not worth knowing what is wrong" haha, so true. I almost always wrap errors at every level with addition context. If it was worth doing, then it's worth explaining. People that prefer try/catching large sections of functionality or want to skip verbose handling of errors often have not thought through the user…

You surely know that it is very common to rethrow the original exception wrapped in languages with try-catch — it still saves you the time to write that (plus it is safe, no code, plus stacktrace). It is still strictly better than whatever go has.

Re: Thirteen Years of Go

#174

Earlier quoted context omitted.

> I had a Python .... IMHO, the biggest win of Go over anything Python is the single distributable. You write once. Compile (or cross-compile) once. Distribute the binary. Job done. Python you've got the hell of dependencies. Write your script once, but then users have to endure pip hell for the hundreds of libraries you've depended on. And then the potential different dependencies between different Python stuff. Go…

Are there reasonable Go alternatives to pandas, numpy, and sklearn?

> Are there reasonable Go alternatives to pandas, numpy, and sklearn?

You got me there. That is one of the things I keep asking Santa to bring me for Christmas. ;-)

I wish someone would come along with a competitive Go ML lib. That would be awesome with a capital A !

There are one or two niche libraries around for specific tasks (e.g. anomaly detection) but there's no broad-scope general ML library.

Re: Thirteen Years of Go

#175
post #156

Earlier quoted context omitted.

Personally, I hate writing Go. It's a very dull and boring language, but it's an amazing language (objectively speaking) for software development. 1) It's performant. The language itself is very fast, the GC is very fast and go routines make concurrency fast. 2) The tooling is great. Once you have the Go CLI installed, everything else "just works." Cross-compilation is super easy. Install dependencies is easy. Genera…

Not sure generics are amazing. I wish I could do something like addresses := persons.map(func(p Person) Address {p.address}) Actually what I really want is addresses := persons.map(p => p.address) But I understand Go doesn't allow that level of readability.

Yes, succinctness is almost never in Go's favor.

Re: Thirteen Years of Go

#176

Interesting to see many comments regarding "Go is my favourite programming tool, but not my favourite programming language". I totally agree. I love the tooling (go build, go fmt, etc.), the performance, the ecosystem... but the language itself is not the best out there. I would love a mix between Python and Go: Python as the language with Go's tooling. That would be amazing!

Write python and transpile to Go.

Re: Thirteen Years of Go

#177
post #62

Earlier quoted context omitted.

If you looked at the spec which provides simple, valid examples that work, then why would you spend hours writing different code wondering why it doesn’t work? The section you linked does explain it, btw. IfStmt = "if" [ SimpleStmt ";" ] Expression Block [ "else" ( IfStmt | Block ) ] . Note there is no newline or semicolon between Block and the optional “else” clause, and a Block is thusly defined: Block = "{" Statem…

To someone coming from C, C++, or Java, the idea that a newline would change the meaning is completely novel. And Go has the same "flavor" as those languages, so most people would expect Go to behave the same unless the difference were called out very explicitly.

I think the absence of semicolons is a pretty big call-out.

Re: Thirteen Years of Go

#178
post #156

Earlier quoted context omitted.

Not sure generics are amazing. I wish I could do something like addresses := persons.map(func(p Person) Address {p.address}) Actually what I really want is addresses := persons.map(p => p.address) But I understand Go doesn't allow that level of readability.

So you just want implicit returns?

I want to be able to define generics on methods, not just functions.

Re: Thirteen Years of Go

#179
post #173

Earlier quoted context omitted.

> are encouraged to add context to the error message instead of "here is stack trace, fuck you user, you're not worth knowing what is wrong" haha, so true. I almost always wrap errors at every level with addition context. If it was worth doing, then it's worth explaining. People that prefer try/catching large sections of functionality or want to skip verbose handling of errors often have not thought through the user…

You surely know that it is very common to rethrow the original exception wrapped in languages with try-catch — it still saves you the time to write that (plus it is safe, no code, plus stacktrace). It is still strictly better than whatever go has.

I've written a lot of try/catch but no one in those languages do that for every branch, it's usually just everything wrapped in a big try/catch.

Go makes you deal with the error every single time something could go wrong, so you have a chance to do the right thing and append context at every single failure path.

Re: Thirteen Years of Go

#180

Earlier quoted context omitted.

Are there reasonable Go alternatives to pandas, numpy, and sklearn?

> Are there reasonable Go alternatives to pandas, numpy, and sklearn? You got me there. That is one of the things I keep asking Santa to bring me for Christmas. ;-) I wish someone would come along with a competitive Go ML lib. That would be awesome with a capital A ! There are one or two niche libraries around for specific tasks (e.g. anomaly detection) but there's no broad-scope general ML library.

Yes, I would also like better C interop speed and better GUI toolkits for desktop apps/games. But hey, that is why we have Rust.
Post reply on HN