Comment by vips7L
> But people never ever agree on what to put in typing system. For example, Java's checked exceptions are a form of typing... and everyone hates them.
I love checked exceptions. Checked errors are fantastic and I think most developers would agree they want errors to be in the type system, but Java as a language just hasn’t provided the language syntax to make them usable. They haven’t made it easy to “uncheck” when you can’t possibly handle an error. You have to write boilerplate:
Something s;
try {
s = something();
} catch (SomethingException e) {
throw new RuntimeException(e);
}
It sucks when you face that situation a lot. In Swift this is really simple: var s = try! something();
Java also hasn’t made them usable with lambdas even though both Scala [0] and Swift have shown it’s possible with a sufficiently strong type system: try {
someCall(s -> {
try {
another(s);
} catch (CheckedException ex) {
throw new UncheckedException(ex);
}
});
} catch (UncheckedException ex) {
// handle somehow
}
It sucks. I’m hopeful one day we’ll get something like try! or try? and better lambdas. Maybe once all resources stop being poured into Valhalla.[0] https://docs.scala-lang.org/scala3/reference/experimental/ca...