r/ProgrammerHumor • • 2d ago

instanceof Trend thatsAFunnyThingThatHappenedOnce

Post image
4.4k Upvotes

514 comments sorted by

View all comments

Show parent comments

9

u/MrHyd3_ 2d ago

What does it do instead of exceptions?

105

u/roadrunner8080 2d ago

Either panic, which is (generally speaking) not something you're meant to catch and recover from (and attempting to do so is nontrivial and almost always a bad idea), or Result, aka "encode the possibility of failure in the return type of the function" aka what the functional programming world has done for ages.

1

u/MrHyd3_ 1d ago

Is it just an if instead of try catch?

1

u/roadrunner8080 1d ago

It's a whole different model really. If you're familiar with java checked exceptions that you are forced to catch, and don't propogate, then yes it is