@hongminhee洪 民憙 (Hong Minhee) Isn't it functionally equivalent to
Result<T, E>
? (except semantic?) The one Java feature I wish TypeScript had.
It's so annoying that exception types don’t get tracked. Even Swift added typed throws in version 6…
Hot take: Despite their bad reputation in the Java community, checked exceptions provide superior type safety comparable to Rust's Result<T, E>
or Haskell's Either a b
—we've been dismissing one of Java's best features all along.
@hongminhee洪 民憙 (Hong Minhee) Isn't it functionally equivalent to
Result<T, E>
? (except semantic?) The one Java feature I wish TypeScript had.
It's so annoying that exception types don’t get tracked. Even Swift added typed throws in version 6…
If you have a fediverse account, you can reply to this note from your own instance. Search https://hackers.pub/ap/notes/0195b69f-dcd2-7ef2-a030-9e5c07ae4a1d on your instance and reply to it.
@nyeongAn Nyeong (安寧) Yes, functionally they're similar—both enforce error handling at compile time! The key difference is that Java automatically propagates exceptions once declared, while Rust requires explicit
?
for each call. Swift adding typed throws is fascinating validation of the concept.
My blog post explores these differences in depth.
The semantics matter though—Java's approach integrates better with imperative code, while Result<T, E>
types fit functional paradigms. Each has its place!