what's the future of error handling?
# thinking-together
m
what's the future of error handling?
❤️ 3
m
Interfaces should be respectful of the work that the user has done up to the point an error occurs. The computer should freeze/salvage as much of the state as makes sense for the context, and provide the ability to resume from there. Kinda like Common Lisp’s condition system, but potentially spanning multiple network nodes, and also surfaced meaningfully in the user land.  It should include contextual suggestions to help “fix” the error, and carry on. Loosely mapping to the Common Lisp restarts. It should speak the user’s language. It shouldn’t gratuitously expose them to the semantic layers beneath. Unless they want to! Which means you need some sort of “moldability” in your error framework.
g
i agree with the above ^ every error should be result in a question from the user about how to proceed, with the opportunity to fix the issue using any required data from a humane interface for finding it
m
and what if the error corrupted state or left it in an inconsistent state?
w
@Mariano Guerra rewind!
🍰 1
m
so the future is immutable? 🙂
d
I don't believe in errors or exceptions, because I believe programming is creating models of reality, and you don't get errors or exceptions in reality.
😭 2
m
how parsing a csv when given a pdf is a model of reality?
d
There are two ways of answering that: from the point of view of (a) syntax as type in a programming model, or (b) interfacing between a clean programming model and the dirty realities of legacy tech
(a) If you expect some shape and don't see it, you don't see it, no errors, just no behaviour. Hopefully your programming environment will help you play with the stuff of your model to enable you to feel and experiment your way forwards
(b) yes, something tells you the data import didn't work, in a log or something; so maybe you can have "error as type": an object in the clean programming environment that was meant to be populated with the CSV data has an "error message"; fair enough! 😄
k
Depends on the future of everything else! It makes no sense to design features separately and then bolt them on. Depends on where in the utopian stack you're talking about. Different places will need different, ahem, trade-offs.
💯 4
d
↑ and what Kartik sez
😑 1
c
Robust Computing
❤️ 1
g
yeah, ideally the error percolates up as a mismatch—for example, somethings undefined. the tool rewinds the execution trace to where that symbol became undefined—gives you the process and lets you edit it such that it doesn’t happen again
similar to how TDD works in a smalltalk image
demonstrated at 1730 2100 in this video (tldr at 1930 2045):

https://youtu.be/eGaKZBr0ga4

d
.. * tl;dw you mean 😄
👌 2
k
I assume @curious_reader is referring to https://www.youtube.com/playlist?list=PLm5k2NUmpIP-4ekppm6JoAqZ1BLXZOztE Very nice internally consistent answer. Fixing error handling this way affects the entire programming model.
👍 1
👆 2
a
I do think @Duncan Cragg is on to something. "Errors" are fundamentally just another control flow path that don't necessarily deserve special treatment. From this I conclude that any shenanigans we want to do with exceptions should also be available for happy-path code as well. I'm pretty sure this means pervasive use of delimited continuations, possibly in the form of algebraic effects.
k
Or anonymous sum types that are structurally rather than nominally matched. Go's pattern but with a single result.
a
@Kartik Agaram can you elaborate a bit on what you mean by "structurally matched"? A doc link to a language that does it would be fine. I'm assuming "nominally matched" is the usual ML-style pattern match...
k
Right. The closest language is https://ceylon-lang.org/documentation/1.3/introduction. Search for 'union type'. Basically structural typing addresses Rich hickey's criticism of Haskell. You don't always want int to match some union type containing ints. But it's good to give programmers the choice. Particularly for errors, it's good to be able to just return an int and have it automatically convert to
int|err
. This approach to error checking feels more parsimonious than first class delimited continuations and algebraic effects.