Hacker News new | past | comments | ask | show | jobs | submit login

Well, 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

[2] https://www.youtube.com/watch?v=Gel8ffr4pqw

[3] https://2020.programming-conference.org/details/salon-2020-p...




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: