guitarvydas
01/31/2025, 1:58 PMFederico Pereiro
02/03/2025, 9:08 PMUNIX pipelines were headed in the right direction, but, the shell pipeline concept has lagged behind advances in FP - and, pipelines were conflated with function calls, which ain't the same thing.Concerning those two points, I'm really curious to hear how that's the case. In my mental model, pipelines are homomorphic to chained functions. I'd love to know how you think that the concept of pipelines could be expanded, or where exactly it is lacking.
guitarvydas
02/03/2025, 10:15 PMguitarvydas
02/04/2025, 4:53 PMFederico Pereiro
02/04/2025, 8:45 PM• The key insight is that pipelines are about modelling data flow, while function chains are about control flow - they're different abstractions serving different purposes.I see function chains as about both data and control flow. In plain language: I do X and get Y; then I give Y to Z and Z does its thing.
• A pipeline only passes data, not control flow.It's true that pipelines are more "continuous", in that the next utility might start working on its input before the previous one finishes generating the output. That's a remarkable difference. But for most practical purposes, I still see them as sequential.
• Pipeline nodes do NOT determine which code runs next [pt: whereas functions do]But neither do the chained functions, right? This decision belongs to the caller, the one chaining the functions in the first place. Overall, I'm not trying to win an argument, just trying to see what I'm missing. Thanks again for sharing your insight!
guitarvydas
02/04/2025, 9:43 PMI do X and get YWith a function, yes. With a node in a pipeline, it's async, hence, you
do X and don't need to wait around. The callee just sends Y further down the pipe without bothering to return it to the caller. Once you break out of the habit of thinking only in terms of functions, other interesting combinations appear beyond just simple, sequential pipelines. [I can discuss further, but, am cutting myself off to KISS]
But neither do the chained functions, right?No. A call passes
control flow immediately to the callee. A function specifies the callee directly, hence, determines which function will run next. A node in a pipeline cannot do this. This is subtle, but, important. In a pipeline node, the node does not call any other node, it simply leaves a result in a queue, to be be dispersed later by a higher power (the "dispatcher" in UNIX, "Choreographer Parts" in my stuff </KISS>).
Dependency injection looks like it sends, but only adds a level of indirection to the naming process, while continuing to choose who gets to run next. Calling and sending deliver data differently. Imagine a queue - call puts the data at the front of the queue, whereas send puts data at the end of the queue.Federico Pereiro
02/05/2025, 5:03 PMFederico Pereiro
02/05/2025, 5:04 PMguitarvydas
02/05/2025, 10:06 PMFunction call: receives input all at once, returns data all at once, doesn't know where the data or control goes to...The word
return is loaded. It surreptitiously contains a scheduling decision AND it surreptitiously contains a routing decision (the callee must send data back to the caller - no choice. The decisions are hard-baked into the syntax.
... reaching for another way to say this (I seem to be batting 0 everywhere I try to expand on this) ...
Syntax such as f(g(h(x))) does not allow for the possibility that j(k(h(x))) gets to run until f(g(h(x))) is finished, i.e. f(...) makes a data-flow decision (stack-based data transfer instead of queue-based data transfer) - AND - it makes a scheduling design - AND - f(...) blocks any other input from reaching h(x) until it decides to allow this.
Let's say you press a key on the keyboard, then click the left mouse button. That's different than a click on the left mouse button followed by a keypress. You can't differentiate these with f(g(h(x))) syntax followed by j(k(h(x))) syntax. F(g(h(x))) is fine if you have a single thread and no feedback. That's the way computers used to be in 1950. Today, computers are no longer like that (internet, robotics, IoT, etc), hence, strict sequential syntax cannot cope with reality any more. The best you can do is to write two async programlets that describe the innards of these things, but, it is hard to write a 3rd program that connects the two (without a lot of futzing and edge-cases and gotchas).
Pure functions are nice if all of your problems can be solved in a sequential manner, but, that ain't the case any more.alltom
02/07/2025, 4:43 AMguitarvydas
02/07/2025, 1:54 PMFederico Pereiro
02/16/2025, 8:07 PM