163
you are viewing a single comment's thread
view the rest of the comments
[-] TimeSquirrel@kbin.melroy.org 8 points 1 day ago

I'm just a hobbyist but...are you guys using exceptions like they're conditional statements?? I thought those were for only when shit is seriously wrong and execution can't continue in the current state. Like if some resource was in a bad state or some input was malformed.

Or maybe I haven't worked on anything complex enough, I dunno.

[-] sbv@sh.itjust.works 12 points 1 day ago

I thought those were for only when shit is seriously wrong and execution can't continue in the current state.

That's how it starts. Nice and simple. Everyone understands.

Until

some resource was in a bad state

and you decide you want to recover from that situation, but you don't want to refactor all your code.

Suddenly, catching exceptions and rerunning seems like a good idea. With that normalized, you wonder what else you can recover from.

Then you head down the rabbit hole of recovering from different things at different times with different types of exception.

Then it turns into confusing flow control.

The whole Result<ReturnValue,Error> thing from Rust is a nice alternative.

load more comments (4 replies)
this post was submitted on 13 Nov 2024
163 points (98.2% liked)

Programmer Humor

32472 readers
647 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS