3 ms·
> Plenty of languages inline map/reduce or iterator type code down to very efficient cache-friendly traversal of memory Very few languages outside of Rust and
by fsdjkflsjfsoij 5y ago
> Plenty of languages inline map/reduce or iterator type code down to very efficient cache-friendly traversal of memory
Very few languages outside of Rust and Haskell actually do this reliably and that's including languages like Ocaml and F#. Rust and Haskell are certainly the only even remotely popular languages that do it.
- spekcular 5y agoDoes Haskell actually succeed here? This is perhaps not the right way to measure, but: When I last checked the programming language benchmark game [0], the Haskell submissions were basically as fast as C/C++/Rust. But, this came at the cost of writing non-idiomatically/non-functionally – essentially abusing the language to write C in Haskell. I would be curious how well "idiomatic" Haskell compares to C++/Rust, in terms of the compiler optimizing away the functional abstractions. [0] https://benchmarksgame-team.pages.debian.net/benchmarksgame/index.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- igouy 5y agoThe benchmarks game isn't limited to one Haskell program per task. Look at both https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/spectralnorm-ghc-4.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... and https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/spectralnorm-ghc-2.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- spekcular 5y agoThanks, that's pretty convincing.
- nine_k 5y agoDoes the elephant-in-the-room of C++ do it? I thought it does. I can't bet on what Java and JavaScript JITs make of map / forEach / filter / reduce, but I suspect that they can be pretty efficient, given the clear delineation and the repeated patterns.
- Zababa 5y agoI think OCaml can do it with flamba, at least that's what this library readme says: https://github.com/c-cube/iter https://github.com/c-cube/iter > with flambda under sufficiently strong optimization flags, such compositions of operators should be compiled to an actual loop with no overhead!