4 ms·
Exception throwing is the goto of 21st century. The article's examples aren't the worst, it's common seeing exceptions for business rules in Java/.NET land.
by talles 11y ago
Exception throwing is the goto of 21st century. The article's examples aren't the worst, it's common seeing exceptions for business rules in Java/.NET land.
- est 11y agoWat? I thought callbacks are the goto of 21st century.
- santaclaus 11y agoI thought plain threads are the goto of the 21st century?
- Mikhail_Edoshin 11y agoExceptions are just a way for a piece of code to say to its callers: "Sorry guys, this is over my head, I give up, sort this one yourselves." And since most pieces are pretty simple, they encounter these situations routinely. Now, if you want things like nice syntax you positively need exceptions at least as a concept. Otherwise you cannot even add two numbers: take `a + b`, what if the result overflows? What if you write `x = foo(y, bar(z))` and `bar()` fails to deliver? Maybe the try/throw/catch syntax is not that convenient, or maybe the documentation doesn't list all the exceptions that may arise and you feel out of control, or maybe a particular implementation is slow; these are all valid reasons. But I don't see how you can get rid of the idea of exceptions. Well, maybe functional languages have something here, but I'm not an expert in this area; my understanding is that you may define a function as returning either `Error` or `UsefulResult` so you can branch accordingly.