3 ms·
Go got this right. Lua also has a nice error mechanism that I haven't seen elsewhere where you can explicitly state where in the call stack the error is occurri
by andrewmcwatters 1y ago
Go got this right. Lua also has a nice error mechanism that I haven't seen elsewhere where you can explicitly state where in the call stack the error is occurring (did I error from the caller? or the callee?).
Similarly, JavaScript seems to do OK, but I miss error levels. And C seems to also have OK error conventions that aren't too bad. There's a handful of them, and they're pretty uncontroversial.
Macros seem to be wrong in every language they're used, because people can't help themselves.
It's like a red flag that the language designers were OK giving you enough rope to hang yourself with, but also actively encourage you to kill yourself because why else would you use the rope for anything else?
- Expurple 1y agoNo, Go didn't get this right. Returning a tuple (a T and an errror) isn't an appropriate tool when you want your function to return either a T or an errror. It's a brittle hack that reqires everyone to use a third-party linter on top. Otherwise that tuple is handled incorrectly too frequently. All of that, because Go keeps ignoring a basic feature from the 1970s [1] that allows to you express the "or" relationships (and nullability). APIs that are easy to use incorrectly are bad APIs. [1]: https://en.wikipedia.org/wiki/Tagged_union#1970s_&_1980s https://en.wikipedia.org/wiki/Tagged_union#1970s_&_1980s
- Expurple 1y agoI've even decided to turn my parent comment into a blog post [1]. It also fixes numerous typos, so qoute the blog version. [1] https://home.expurple.me/posts/go-did-not-get-error-handling-right/ https://home.expurple.me/posts/go-did-not-get-error-handling...
- andrewmcwatters 1y agoI’m honored you disagree with me enough to write your thoughts on the matter. Thank you for your insight.
- Expurple 1y agoCan't tell if it's sarcasm or not
- andrewmcwatters 1y agoNo, I'm not being sarcastic. It's easier to ignore a comment than it is to discuss the topic.
- Expurple 1y agoWell, I just have an intrinsic interest in discussing this topic deeply and understanding it deeply. So far, all of my technical posts on the blog have been about error handling
- pjmlp 1y agoNo it didn't, because it failed to provide an alternative to the boilerplate error checking, like Odin, Rust, Swift and Zig, or monadic composition functions.