Hacker News new | ask | show | jobs
by enricosada 3490 days ago
What's the difference with http://nessos.github.io/Streams/ for F#/C# ?
2 comments

The design and implementation of this library was led by my co-author Nick Palladinos and it ports the design of Java 8 streams to CLR.

Check the structure of this library following the definitions of Run in line 41 [1] upwards. You will notice that the code is in continuation passing style. If you combine the signatures (which are there to handle different cases of execution) they could easily be e.g., ('t -> bool) -> bool. But the implementation is more elaborate than that and note that nothing is rewritten. The design relies on the smartness of CLR/JIT to exploit that structure and inline loops. I have just described a firstly push-based, library design. You can check the differences with pull-based in the Clash of the Lambdas [2] paper.

The strymonas library is pull-based first (combined with the push-based approach) to accommodate more cases in a fundamental pull-based way. On top of that we use multi-stage programming as you saw in the paper as we don't want to rely on a sufficiently smart JIT compiler. We use staging to generate tight-loops, fused, without space leaks.

[1] https://github.com/nessos/Streams/blob/master/src/Streams/St...

[2] https://arxiv.org/abs/1406.6631

The strymonas optimal performance is guaranteed for any combination of stream processors. That doesn't seem to be the case of this library which relies on frequent patterns.