How close can pure functional programming get to C?
In the article "Why Lean is Faster Than Rust," the author presents a remarkable finding: a DEFLATE compression library crafted in Lean 4, a functional programming language and proof assistant, surpasses a comparable Rust package with over a billion downloads. According to the article, lean-zip maintains the same compression at higher throughput.
However, lean-zip falls short when compared to libdeflate, the top performer in DEFLATE performance, written in C. Despite this, Roc, a functional programming language with a focus on runtime performance, could potentially bridge the gap. Roc's design emphasizes both speed in running and compiling, and while it's still in its early stages with a nascent package ecosystem, it boasts a strong foundation for performance improvements.
The author, after optimizing roc-deflate, a package written by Niclas Ahden, aims to reduce the performance gap between Roc and libdeflate, particularly focusing on non-streaming APIs. The benchmarks, conducted on a 2021 M1 MacBook Pro and an AMD Ryzen 9 3900X, indicate that roc-deflate lags behind libdeflate in most cases by around 8.9% in the median performance for the AMD Ryzen 3900X, and 2.6% on the M1 MacBook Pro.
Written by urgent.news from Hacker News's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.