4 ms·
Pipelining is just syntactic sugar for nested function calls. If you need to handle an unhappy path in a way that isn’t optimal for nested function calls then
by hnlmorg 2y ago
Pipelining is just syntactic sugar for nested function calls.
If you need to handle an unhappy path in a way that isn’t optimal for nested function calls then you shouldn’t be nesting your function calls. Pipelining doesn’t magically make things easier nor harder in that regard.
But if a particular sequence of function calls do suit nesting, then pipelining makes the code much more readable because you’re not mixing right-to-left syntax (function nests) with left-to-right syntax (ie you’re typical language syntax).
- EVa5I7bHFq9mnYK 2y agoI think they are talking about nested loops, not nested function calls.
- hnlmorg 2y agoNested loops isn’t pipelining. Some of the examples make heavy use of lambda so they do have nested loops happening as well but in those examples the pipelining logic is still the nesting of the lambda functions. Crudely put, in C-like languages, pipelining is just as way of turning fn(fn(fn())) Where the first function call is in the inner, right-most, parentheses, into this: fn | fn | fn …which can be easily read sequentially from left-to-right.
- EVa5I7bHFq9mnYK 2y agoPipelining replaces several consecutive loops with a single loop, doing more complex processing.
- hnlmorg 2y agoPipelining doesn’t do anything with iterating. It’s entirely about linking nested functions. What you’re looking at is loops defined inside lambda functions. Pipelining makes it much easier to use anonymous functions and lambdas. But it doesn’t magically solve the problem of complex loops.
- alganet 2y agoIt kind of is something related to loops if the language supports object iterator interfaces (they bridge OOP to classical constructs like for/foreach). Or maybe even generators. It does not solve it magically, but it does give the programmer options to coalesce different paradigms into one single working implementation.
- hnlmorg 2y agoSure, but again, you’re talking about using either lambda functions or object methods. The crux of the “magic” with pipelining is chaining functions. How those functions are composed and what they do is a separate topic entirely.
- alganet 2y agoIt's only magic if you don't understand how it works. To me it is awkward to describe but simple to understand. Lucky me I have no intention of describing it.
- hnlmorg 2y ago> It's only magic if you don't understand how it works. That’s why I used scare quotes around the term ;) > To me it is awkward to describe but simple to understand. It’s not awkward to describe though. It’s literally just syntactic sugar for chaining functions. It’s probably one of the easiest programming concepts to describe. From our conversation, I’m not sure you do understand it because you keep bringing other tangential topics into the fold. Granted I don’t think the article does a great job at explaining what pipelining is, but then I think it’s point was more to demonstrate cool syntactic tricks you can pull off when writing functions as a pipeline. edit: just realised you aren't the same person who wrote the original comment claiming pipelining was about iteration. Apologies for getting you mixed together.
- EVa5I7bHFq9mnYK 2y ago