Live data from Hacker News

Declined Proposal: A built-in Go error check function, “try”

github.com

371–380 of 425 posts

Re: Declined Proposal: A built-in Go error check function, “try”

#371

Earlier quoted context omitted.

Absolutely. But those are clear code smells. Any org with competent code review would flag them and kill them before they proliferated.

Have you seen the internals of the Go http library? :)

Have you seen the internals of the rand library? HTTP uses interfaces cleverly to detect optional interfaces. Today I found out that rand.Rand does a type check on every core method to see if it’s source is the hidden type for global methods.

Re: Declined Proposal: A built-in Go error check function, “try”

#372

Earlier quoted context omitted.

Would you consider k8s to be developed by a competent org? They have 2324 func declarations that take or return an interface{} on master right now.

Kubernetes, like Docker, is notoriously bad Go. The authors essentially transliterated Java.

This. It was really hard to enforce supplementary style across my team to match common conservatism in popular codebases (e.g. only return a single value or a value and bool/error. Don’t expose channels in APIs) when K8s so blatantly fails them.

Re: Declined Proposal: A built-in Go error check function, “try”

#373
post #193
post #154

Earlier quoted context omitted.

How returning (val, err) is error prone? It's verbose but it's clear and definitely not error prone. I spent so much time working with Java and useless giant stacktraces or with Python and people not knowing what to do inside a try / except.

Copy/paste is very error prone. Golang code is full of it. I see lots of similarities between Visual Basic and Golang, incl. the passionate communities behind the languages.

With the difference that Visual Basic is an academic language full of needless features from Go's community point of view.

Re: Declined Proposal: A built-in Go error check function, “try”

#374

Earlier quoted context omitted.

> Do I particularly like managing errors that way? No, but I do think that it improves the transparency and quality of a lot of Go projects. So long as we can all agree that it feels super bad, I guess this is fine. But it does sort of mean that Golang approaches the Java world back with checked exceptions where principle trumped ergonomics. That lead to a world where folks felt "forced" to use Java, and that's a sti…

You can't compare it to Java checked exceptions. Java checked exceptions are one of those billion dollar "mistakes". It is the single worst thing in Java for me. Checked exceptions add nothing and break almost everything around clean design & code. For that comparison to work, java would have needed to only have checked exceptions, with some added language features to deal with them cleanly, and then it might actuall…

Java checked exceptions were copied from CLU, Modula-3 and C++, even though Java's somehow made them famous.

And even C++, after dropping exception specifications in C++17, might get a simplified version back in C++23 as part of value based exceptions proposal.

Re: Declined Proposal: A built-in Go error check function, “try”

#375

Earlier quoted context omitted.

> Littering your code with try-catch is what makes exceptions infeasible for error handling. I honestly don't see the big difference between littering your code with if/else blocks versus littering them with try/catch blocks. Can you elaborate?

If/else provides a clear and easy to follow control flow. try/catch is like a roaming goto that works it's way back up your stack in ways you can't predict. http://www.lighterra.com/papers/exceptionsharmful/

The context here is Java's checked exceptions, which have to be handled explicitly at the site where they may occur, leading to control flow that - in my view - isn't substantially different from handling errors with if/else.

Re: Declined Proposal: A built-in Go error check function, “try”

#376

Earlier quoted context omitted.

> Littering your code with try-catch is what makes exceptions infeasible for error handling. I honestly don't see the big difference between littering your code with if/else blocks versus littering them with try/catch blocks. Can you elaborate?

Both are bad.

What's the alternative?

Re: Declined Proposal: A built-in Go error check function, “try”

#377

Earlier quoted context omitted.

The controversy may have died down, but the impact on code written would have been permanent. There's a lot of value to there being "one way to do things", even when it's not the best way from any particular point of view. Go holds this principle higher than most other languages and I think that should be either embraced, or one should look elsewhere - and I'm saying that as someone who "looked elsewhere".

Agreed, no one is forced to use Go. I think it is refreshing to see a language like Go. You don't want all languages to asymptotically approach each other in features. We need diversity in our languages, that way you have flavors to choose from.

Just wait until management comes around with idea to write Docker or K8s plugins.

Using a programming language is not always an option.

Re: Declined Proposal: A built-in Go error check function, “try”

#378

Earlier quoted context omitted.

Typing “if err != nil { return nil, err }” a million times is not thought.

To be fair, any decent editor will expand 'er' to that, no need to type it manually.

So a typical criticism of Java and IDE dependency becomes a non-issue when talking about Go's shortcomings.

Re: Declined Proposal: A built-in Go error check function, “try”

#379

Earlier quoted context omitted.

Experts' code should be clearer and more concise than novices' code. If that's not true, there's no payoff for getting more proficient with the language, and it's not doing enough to help you.

golang is not primarily designed for experts "The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to und…

Ironic in a company that prouds itself of PhD hiring games.

Re: Declined Proposal: A built-in Go error check function, “try”

#380

Earlier quoted context omitted.

If/else provides a clear and easy to follow control flow. try/catch is like a roaming goto that works it's way back up your stack in ways you can't predict. http://www.lighterra.com/papers/exceptionsharmful/

The context here is Java's checked exceptions, which have to be handled explicitly at the site where they may occur, leading to control flow that - in my view - isn't substantially different from handling errors with if/else.

Fair enough.
Post reply on HN