3 ms·
This is a good answer and gets to the heart of what's been throwing me - cultural and technical differences. > I'll claim, though, that if one is capable of co
by throwaway_pdp09 6y ago
This is a good answer and gets to the heart of what's been throwing me - cultural and technical differences.
> I'll claim, though, that if one is capable of computing these situations up front and preparing the recovery strategies ahead of time, then we're no longer doing exception handling whatsoever. If you are able to compute all situations up front, then you don't have exceptional situations, so you don't have exceptions and therefore don't need need exception handling!
Exactly! This is a cultural difference; in my world you should only use exceptions for things that should never happen, but I suppose 'never' is a matter of expectation and therefore code that follows that expectation.
> This is why one may also decide to solve this example by using a strong type system
Agreed, and to me this is the 'correct' solution. But that may be a counsel of perfection (and an overbearing cultural 'arrogance' on my part)
> That doesn't need to always be the case. Let's suppose that we've just run into the error and need to fix it - the situation that you described, an interactive hotfix of a running system.
This is both cultural and technical difference that I've been struggling with. This makes it clear what you're getting at.
> If you can successfully use the "parse, don't validate" pattern[...]
Not heard of this. You've given me some reading to do, thanks. For those unfamiliar, https://html.duckduckgo.com/html?q=parse%2C%20don%27t%20validate https://html.duckduckgo.com/html?q=parse%2C%20don%27t%20vali...
> We likely might need to develop a patch for that module where we now know that it has a fault and we may also need to live with it for X days before it is fixed upstream. When we have error-handling information stored in the dynamic environment and restart points sprayed across our stack, we have a situation where the error can be handled both without recompiling that faulting module and without destroying the stack - computation can continue when we've provided a proper recovery routine.
That is a compelling use case.
> We aren't getting crashes, stacks are not getting completely unwound.
I came across Lisper's enthusiasm for such exception handling ability (based on having the stack not-unwound) when I was trying to learn Dylan, a long time ago. I'm starting to see what they were getting at. That doesn't mean I'm comfortable with it, but I do understand it rather better now.
> along with the fact that Lisp is an interactive system (a lot of Lisp's power simply disappears when it's used like Java or Rust or any other batch language) [...] We can fix it interactively, and possibly store this fix in a new condition handler that we then patch on top of our running program [...] But the condition system has served its purpose by then! It helped us keep the system alive and fix the issue on the spot [...] These solutions are no longer about exception handling; they are modifications to the standard control flow of the program. They aren't trying to fix the situation from outside; they are trying to fix the situation from the inside. And fixing it from inside isn't always viable or even possible at all [...] This is achieved first and foremost by allowing human intervention: the debugger is started, the stack information is preserved, so a programmer has all the information to try and debug the situation to let the program continue execution
OK, these explicit statements are very important and revealing.
> ...apologize for the wall of text
No need, it's an excellent answer, it's just a perspective that does not come from 'my side of the tracks'.
Glad I persisted, I feel I've learnt something important today. Good luck with the book!
- phoe-krk 6y agoThank you! I'm also glad that I've managed to give you a satisfying answer. How should I credit you in the book's Hall of Fame?
- throwaway_pdp09 6y agoNo credit needed. 'anonymous HN poster' if you really want to put anything at all but I'm fine with nothing.
- phoe-krk 6y agoOK - will do that. Thanks.