Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'd get annoyed too, because I know there are much simpler alternatives. Language design should encourage doing things right by making it more convenient than the shortcuts.

In Rust that entire check can be a single "?" symbol. How much syntactic sugar is too much is a matter of preference, but I personally think that properly handling all errors without syntactic sugar turns into an unreadable mess because there's just a lot of things which could go wrong.



almost 50% of the time i want to add some debugging info to the error before forwarding it one layer above, to provide more context.

I think just forwarding all low-level errors is a really bad habit, and go forces you to at least think about this.


> I think just forwarding all low-level errors is a really bad habit

Why exactly is that a bad habit? In almost all situations where I return an error I already have enough context, I'm just wondering what else I'd add to that.

> go forces you to at least think about this

Boilerplate code definitely doesn't incentivize thinking.


most errors you encounters are with i/o and are stupid "can't read, can't write or can't serialize".

In a network environment (which is originally what go was made for) you often need to add tracing information, business-level identifiers or processing information related to your state etc.

I'm currently writing a fairly complex api in go, and to be honest this really hasn't bothered me once.

Not to say it doesn't exists, but with time i've come very suspicious of people complaints over go. Most of the time those complaints come from people that didn't realize they missed an opportunity to have written a much much more elegant solution to their problem.


or usually just try again with backoff.


just returning the error isn't handling it.


I never said it is, but to handle an error you have to pass it to the caller that can actually do something with it, whether it's trying alternatives, repeating the step, just logging it, or whatever else - a lot of functions just need to pass it on a couple of times and making this verbose in every single case doesn't make sense to me.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: