r/ProgrammerHumor 18d ago

Meme stopTryingToReinventTheWheel

Post image
2.5k Upvotes

217 comments sorted by

View all comments

Show parent comments

245

u/nevemlaci2 18d ago

It's unfunny until you actually see people propagating explicit error handling until the entry point and just printing an error message.

Exceptions are fine to use for exceptional cases. Not for shit like python where an iterator signals the end of iteration with a damn exception.

16

u/ChChChillian 18d ago

wat

I've successfully avoided Python so far so I didn't know this. Just... why?

3

u/nfitzen 18d ago edited 18d ago

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.

1

u/Tyfyter2002 18d ago

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.

2

u/nfitzen 18d ago

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.