|
|
|
|
|
by thinkharderdev
597 days ago
|
|
Very true, but I do think there is an issue in the margin about how easy it is to ignore errors. For example, in Java you might have something like ```
void checkPermissions() throws AuthException
``` so you have to actively ignore errors by catching the exception. Likewise in Rust you can do ```
fn check_permissions() -> Result<(),AuthError>
``` In that case you can just use the `?` operator to short-circuit (and clippy will warn you if your forget to do that). In other words, while language design can't fully prevent you from ignoring precondition checks, it can make it harder to forget or even force you to actively ignore precondition failures |
|
Obviously you are not forced to think of the user when designing an API, but you don't have to be mindful of the user in any language. Not even Haskell can save a developer who doesn't care, as noted in an earlier comment.