I rag on “if err != nil { return err }”, but I can sort of understand where people who prefer it to try/exceptions are coming from, even though I completely disagree. But I can’t even begin to understand people who prefer hand-written state machines to async/await.
-
-
Replying to @pcwalton
Whenever people talk Go's "readability", I can't get over how every line of actual code is buried in an additional 3+ lines of redundant error handling boilerplate. "...but you get used to it!" is the counterargument, and one I think can be used to justify anything as "readable"
4 replies 4 retweets 33 likes -
If you actually add some valuable context and not just "return err", it makes a lot of sense. I like it, because the control flow is so explicit.
1 reply 0 retweets 1 like -
1 reply 1 retweet 3 likes -
Wow, that is just ugly. That is not the price I'm going to pay for saving one line of code. I mostly use fmt.Errorf("failed to foo with bar: %s", err), which not only adds context, but at the same time, tells the reader what I was actually trying to do, thus documenting the code
1 reply 0 retweets 0 likes -
In Rust I can write try!(f(…).map_err(MyErr::FooFailed)); which is just as clear and shorter.
2 replies 0 retweets 2 likes -
I think the “explicit control flow” buys nothing at all when panics can cause invisible stack unwinding almost everywhere.
3 replies 0 retweets 8 likes -
Invisible code paths are such a dangerous concept, IMO. In C++, there's a reason you have to manage resources with a designated class, and that's because an invisible error might be thrown, at best causing resource leaks.
1 reply 0 retweets 0 likes
Once you have panic exceptional control flow is something you will always have to deal with. The only alternative is panic=abort, which is a ship that’s long-since sailed in both Rust and Go.
-
-
Replying to @pcwalton @KardOnIce and
My point is that if you want a consistent philosophy about control flow then you can’t just be against try; you need to be against panic as well.
0 replies 0 retweets 3 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.