8 ms·
I think they are talking about nested loops, not nested function calls.
by EVa5I7bHFq9mnYK 1y ago
I think they are talking about nested loops, not nested function calls.
- hnlmorg 1y 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 1y agoPipelining replaces several consecutive loops with a single loop, doing more complex processing.
- hnlmorg 1y 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 1y 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 1y 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 1y 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 1y 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 1y agoPipelining, as discussed in the linked article, is about iteration. Just look at the code example at the beginning of the article: data.iter() .filter(|w| w.alive) .map(|w| w.id) .collect() is one loop, as opposed to collect(map(filter(iter(data), |w| w.alive), |w| w.id), which is three loops. Did you notice four letters 'i', 't', 'e' and 'r' in the code, followed by two round brackets? They mean "iterator".
- hnlmorg 1y ago