A Lean 4 DEFLATE compressor recently surpassed a popular Rust implementation but remained far behind libdeflate, a highly tuned C library that uses architecture-specific SIMD. This result prompts a test of whether Roc, a functional language designed for performance, can get closer to C. Roc is still pre-release and its package ecosystem has seen little optimization, but the author argues its language design and compiler provide a strong enough foundation to challenge libdeflate. The test focuses on roc-deflate, a DEFLATE package used in production, and its non-streaming compression APIs; the implementation was checked to produce identical output.
After extensive optimization, roc-deflate came within striking distance of libdeflate on the Silesia benchmark corpus. Across 144 benchmark cases, it was slower on average, with a median gap of 8.9% on an AMD Ryzen 9 3900X and 2.6% on an M1 MacBook Pro. The comparisons cover compression levels and a range of files, with each result based on the median of 15 runs. The findings suggest that a functional language can approach C performance even before its first stable release, though roc-deflate did not beat libdeflate overall and lacks streaming support. The test therefore shows both the potential of Roc’s performance-oriented design and the remaining distance to a mature, architecture-specialized implementation.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.