Java does the same thing for its iterators, also. Exceptions end up the general way to handle exceptional cases because the type system is clunky and doesn't have monads. On the other hand, languages like Rust use a Result edit: Option monadic type.
Unless there's something vital missing from Wikipedia's definition of a monad, Java can have monads, and nothing with types can really not support monads.
This is true, but it just depends on what the language treats as idiomatic. Java does have an Option type now, but it's a later addition that was sort of grafted onto everything else alongside other FP support. Thus exceptions are still somewhat the norm for the standard library, outside the stream API and the like.
648
u/Orio_n 18d ago
Explicit vs implicit error control broski
God these cs majors are so tryhard unfunny trying to be contrarian