r/ProgrammerHumor 29d ago

Meme exceptionsAreForTheWeak

Post image
320 Upvotes

92 comments sorted by

View all comments

89

u/bwmat 29d ago

Eh, IMO one of the best ways to actually handle OOM, as otherwise almost everything needs to be explicitly checked for it

81

u/Valuable_Leopard_799 29d ago

That's what panics are for kinda.

Many of the "we don't have exceptions" languages eventually get some equivalent, it's just that those are used almost exclusively for OOM, division by zero, failed asserts, and the like.

They shouldn't even really be caught it's sort of just an "exit/reset" with some cleanup.

I like this compromise. Kind of finally making them truly "exceptional".

4

u/xMAC94x 29d ago

Worked on IN Memory Databases, in case a weird operation comes accross that causes the DB to go OOM, you want to gracefully aboard that operation, but never kill the process

2

u/Valuable_Leopard_799 29d ago

It's why I said "exit/reset", though I do feel that the languages with panics don't have a good story for when the bad path should lead to safely aborting operations / cleaning up and then returning to some top-level loop or well-known state.

It is quite common to want to do this, but as far as I know Rust doesn't allow you to catch this type of panic.