this post was submitted on 22 Jul 2025
413 points (98.1% liked)
Programmer Humor
28535 readers
1119 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
It is fair to have a preference for exceptions. It sounds like there may be a misunderstanding on how
Optionworks.Have you used languages that didn't have
nulland hadOptioninstead? If we look at Rust, you can't forget not to check it: it is impossible to get theSomeof anOptionwithout dealing with theNone. You can't forget this. You can mess up in a lot of other ways, but you explicitly have to decide how to handle that potentialNonecase.If you want it to fail fast and obvious, there are ways to do this. For example you, you can use the
unwrap()method to get the containedSomevalue or panic if it isNone,expect()to do the same but with a custom panic message, the?operator to get the containedSomevalue or return the function withNone, etc. Tangentially, these also work forResult, which can beOkorErr.It is pretty common to use these methods in places where you always want to fail somewhere that you don't expect should have a
Noneor where you don't want your code to deal with the consequences of something unexpected. You have decided this and live with the consequences, instead of it implicitly happening/you forgetting to deal with it.