4 ms·
Well, this has a lot of practical knowledge on offer, and I intend to watch it a few more times for it all to sink in. I've always believed that anyone can lea
by mikewarot 5y ago
Well, this has a lot of practical knowledge on offer, and I intend to watch it a few more times for it all to sink in.
I've always believed that anyone can learn anything, if they and their teacher both believe it, and put in the effort. I'm glad to see that bias confirmed.
I was really surprised that nobody seems to actually handle errors. This does reflect my experience, in what I thought (until now) was an exception. In about 1985 I was taking a vendor taught course in PL/N at the Norand company (who made hand-held computers used for inventory management). We got to the section of the course about error handling. They described the syntax for checking errors, and how to format things, etc. I asked what happened when you got an error, and both instructors had never been asked that question, and both had ZERO clue about it.
For all the arguments here about in and out of band error handling, this was shocking, and definitely did not confirm any bias.
- dharmaturtle 5y agoI'm a big fan of "Railway Oriented Programming" [1]. Basically your code has two paths - the "Ok" route and the "Error" route. Your code won't compile unless you handle the Error case. However, it requires language level support to use easily - you need mutually exclusive types like discriminated unions. It's harder to do in most OO languages like C#/Java/Javascript, but you can do it with some effort. Which is why most don't. [1]: https://fsharpforfunandprofit.com/rop/ https://fsharpforfunandprofit.com/rop/
- mpweiher 5y agoWhile ROP is better than some current ways, I vastly prefer dataflow (pipes/filters) as a technique. The fundamental problem, IMHO, with error-handling is the call/return nature of most of our programming languages. That means you have to return something from you function/procedure. If you have nothing to return (error) or nothing to return yet (async), you have a problem, particularly with intermediate functions that don't really know what happened below them and don't really have enough of the context from their callers to handle the error. Exceptions allow you to skip the these intermediate layers. ROP makes you handle all those layers, but gives you some tools to help make sure you did it correctly. Filters, on the other hand, do not return results. Instead they actively pass their results on to the next filter in line. That means that in the case of an error, they can do what functions/procedures cannot: simply not produce a result at all. The next filter will be none-the-wiser. You can then have the filter have an out-of-band mechanism for actually dealing with the error, analogous to Unix stderr.
- dharmaturtle 5y ago> The fundamental problem, IMHO, with error-handling is the call/return nature of most of our programming languages I actually consider this a benefit, not a problem. The alternative, as I see it, is to side effect... which 99% of the time is a bad idea if there's an alternative. > particularly with intermediate functions that don't really know what happened below them and don't really have enough of the context from their callers to handle the error If you write a `map` function, you can use it in your pipeline to map over the Ok case and your intermediate functions don't need to know they're taking an Ok|Error type. This is exactly the same as what occurs in the `map`/`select` higher ordered function that's on the `list` type. The function passed to map/select doesn't know that it's being used on a list. In the same way, the function being passed to `Ok.map` doesn't know that it's being used on a discriminated union. > You can then have the filter have an out-of-band mechanism for actually dealing with the error, analogous to Unix stderr. To me this is a side effect and should be avoided. Basically your filter is partitioning your list into two lists, one of OKs and one of Errors, logging the errors, and then not reporting anything back to the consumer. LMK if I'm misunderstanding.
- mpweiher 5y agoWell, I think you are filtering things through a lens that is so limiting that it might as well be misunderstanding. This lens, this filter, is so ubiquitous that as far as I can tell, most people can't recognise it. I call it The Gentle Tyranny of Call/Return [1][2][3] > side effect... which 99% of the time is a bad idea Nope. A filter does not have "side" effects. It has effects, as in what you want to achieve. And it turns out that having an effect is a good idea about 100% of the time, because otherwise your program is 100% useless. Now when your primary architectural style is call/return based, effects of the program that are not encoded in the return value do become "side" effects, but that's a limitation of call/return (which FP turns up to 11), not a problem of effects in general. > > You can then have the filter have an out-of-band mechanism > To me this is a side effect and should be avoided. Why? Apart from the religious mantra of "it is a side effect"? When I adopted this pattern, it turned out to be hugely beneficial. It keeps your happy-path happy, no need to pollute it at all with error handling concerns. And it lets you customise and centralise your error handling, which turns out to be what you usually want, but without the call-stack shenanigans of exceptions. ROP kinda sorta attempts to do something similar, but due to the constraints of C/R, it turns out to be far more complex. [1] https://dl.acm.org/doi/10.1145/3397537.3397546 https://dl.acm.org/doi/10.1145/3397537.3397546 [2] https://www.youtube.com/watch?v=Gel8ffr4pqw https://www.youtube.com/watch?v=Gel8ffr4pqw [3] https://2020.programming-conference.org/details/salon-2020-papers/5/Can-Programmers-Escape-the-Gentle-Tyranny-of-call-return- https://2020.programming-conference.org/details/salon-2020-p...
- frank_nitti 5y agoI also believe anyone can learn anything, exactly as you said! But I don't find the study about grade distributions a convincing argument for that, unfortunately. Grades are a measure of student's ability to apply consistent effort on assignments and effectively study for an exam, often collaborating with a network of other students to find the correct solutions. A determined student can earn a good grade. A determined student can master the material. There is overlap, but not enough to use a premise that Grades<=>Ability A more convincing study would find a way of evaluating their individual ability to solve problems related to what they are supposed to have learned, not their grade in the course.
- rbjorklin 5y ago> I also believe anyone can learn anything, exactly as you said! > But I don't find the study about grade distributions a convincing argument for that, unfortunately. That does indeed seem like a faulty argument. Wouldn’t there be heavy selection bias? It seems incorrect to draw the conclusion that anyone can learn programming based on the grade distribution of a university level CS class.
- perlgeek 5y agoThere's a huge bias towards the happy case in specifications, user stories and so on. I try hard to discuss error cases, but often I only get a very unenthusiastic "well, show an error message, d'oh" as a response, which wears me out over time. This is worse for non-interactive things, like event handling. There's no person to show the error to, usually logging and aborting are kinda the only possible actions, which is endlessly frustrating.
- bwship 5y agoIn the systems I build, I always have the lambda's throw the error to Slack. I have been told many times, that is crazy, and that it doesn't scale. By guess what, when a developer's errors are blowing up a slack channel, they always get fixed.
- amirkdv 5y agoDid this actually lead to better error handling? I'd be worried that it leads to silent idioms of "catch-and-drop" to silence the Slack blow up
- bwship 5y agoThere is a risk with it that you just ignore it. We always put it into a separate room for dev staging and prod. So, what will often happen is you might start to see more errors occurring once you push to staging and your tests are running. It doesn't replace tests and the like, and isn't a cure all in terms of how to handle errors, but I have found it pretty helpful. Especially with serverless, because observability is one of the hardest parts of this paradigm.
- mixmastamyk 5y ago> I asked what happened when you got an error, and both instructors had never been asked that question, and both had ZERO clue about it. No comprendo. Did you mean, what was supposed to happen? Sounds very context-dependent to me. Sometimes you'll pause and show the user the error, sometimes you'll log it and move on, and if it is fatal you'll shutdown immediately to prevent further harm.
- mikewarot 5y agoThe language had error handling constructs, but in the years they'd been teaching the course, nobody had ever asked how the error handling actually was to be used in practice. I found it shocking that nobody cared about error handling, especially on a platform that generated programs to be used by non-computer literate civilians.
- mixmastamyk 5y agoPerhaps the instructors had no practical industry experience, it happens. In my experience, newbie students are working hard to get things working correctly in simple cases. So error handling feels like a luxury at that point.
- mikewarot 5y ago>Perhaps the instructors had no practical industry experience, it happens. What worried me more was when they said nobody had asked that kind of question before, across years of teaching.
- mixmastamyk 5y agoYes, as I mentioned it’s not a concern of newbies, they need to be taught that it is an important concern.