3 ms·
Stream overheads exists, but I have never understood why. Take the example of Java: Why are loops faster than using streams (in most cases)? Shouldn't the opt
by hackingthenews 6y ago
Stream overheads exists, but I have never understood why.
Take the example of Java:
Why are loops faster than using streams (in most cases)? Shouldn't the optimizer/jit be able to see that most streams (even chains of map, filter and reduce etc) are equivalent to simple loops and just optimize away the overhead (in the cases where loops are (obviously) faster; non-parallell, serial computing)?
- Jtsummers 6y agoThat's exactly what Series does in Common Lisp. [0] https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node347.html https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node347.html
- hackingthenews 6y agoAlso Lazy data structures can achieve this. And C++ (and rust probably) compilers have no issue doing these optimizations as well.