2024-11-14 π programmerhumor β RE: yogthos
I'm just a hobbyist but...are you guys using exceptions like they're conditional statements??
https://kbin.melroy.org/m/programmerhumor@lemmy.ml/t/563221/-/comment/4884265
You donβt want to use exceptions in normal control flow, because theyβre extremely slow. Every time you throw an exception, it has to collect a stacktrace, which is hundreds, if not thousands, [β¦]
2024-11-14 tunetardis β 1π¬
I suppose it depends on the language? For the most part I think youβre right. Exceptions are only used (if at all) in situations where a program diverges unexpectedly from its normal flow. But [β¦]
I thought those were for only when shit is seriously wrong and execution canβt continue in the current state.
[β¦]
You can set up a global exception handler in some frameworks. By having multiple (not a crazy amount) of exceptions, you can set up logic for how to handle that kind of error. Then you can just [β¦]
As a rule, exceptions should indeed be used for behaviors that are outside normal execution flow. For example, you might throw an exception if a file youβre trying to access doesnβt exist, or a [β¦]
ββββ
ββββ