What’s the best argument to made made in favor of ... untyped errors in strongly typed languages?
-
-
Replying to @copyconstruct
Just call out
@pathofshrines by name why don't you1 reply 0 retweets 12 likes -
But seriously, the reasons I see are: - Beyond a local frame, types don't really help "make invalid states unrepresentable" because the way large systems fail is open-ended - Types encourage different representations of the same error, because you end up wrapping them
4 replies 0 retweets 26 likes -
Empirically, Java tried it and programmers did everything in their power to squirm out from it
2 replies 0 retweets 7 likes -
Yeah but I don't think that was a fault of typed errors, it was a fault of how their type system interacted with it. If an interface let implementors state what errors they could return, that would fix most of the issues. TBH I don't know how to make it work well with inheritance
1 reply 0 retweets 2 likes -
I think the biggest thing that Rust folks have zeroed in and agreed on is that typing is more important for libraries than applications. Libraries should return enums of their errors and give applications a chance to recover, apps usually just need a `Box<dyn Error>`
2 replies 1 retweet 3 likes -
Interesting, I would've expected the opposite. Libraries returning enums of their errors means they can never grow new errors without breaking clients
2 replies 0 retweets 0 likes -
You can mark an enum as non-exhaustive, which requires any `match`es outside the crate to have a default branch
1 reply 1 retweet 4 likes -
For errors that's pretty much always what you'd do anyway, since if consumers care about any of your error variants it's probably only only one or two
1 reply 0 retweets 1 like -
Nice, swift enums have the same functionality. However, at that point it seems to me the specific error type isn't doing much for your clients
3 replies 0 retweets 1 like
You get ABI stability for your tradeoff though so it's not exactly apples to oranges
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.