A heavily optimized DEFLATE implementation written in the functional language Roc has come within single-digit median performance margins of libdeflate, a mature C library tuned with architecture-specific SIMD instructions. The result offers a narrow but concrete test of how much performance a pure functional language can deliver without exposing programmers to unsafe escape hatches.
Developer Richard Feldman tested roc-deflate against libdeflate across 144 benchmarks drawn from the Silesia compression corpus. The comparison used non-streaming APIs, because roc-deflate does not yet implement streaming, and verified identical compressed outputs. On an AMD Ryzen 9 3900X system, roc-deflate was 8.9% slower in the median case. On a 2021 M1 MacBook Pro, the median gap narrowed to 2.6%.
Those medians did not describe every workload. Roc's implementation was as much as 18% slower on its worst-performing inputs and slightly more than 18% faster on its best. Feldman cautioned that this does not mean Roc has surpassed C: the implementations differ, and equivalent optimization work in C could close cases where Roc currently leads. The broader C performance ceiling remains higher because Roc preserves checks and runtime guarantees that lower-level code can omit.
Roc uses automatic reference counting, performs bounds checks and does not offer a Rust-style unsafe mode. Its type system also supports pure functions, which constrain side effects and make behavior easier to reason about. The compression package therefore trades some theoretical peak performance for guarantees intended to reduce memory-safety failures and unpredictable behavior.
Several optimizations behind the result are familiar across languages, including reducing unnecessary work inside loops. Others rely on Roc's design. Opportunistic mutation lets the compiler update uniquely owned values in place, despite the functional programming model. Developers can also structure code so the compiler proves a bounds check will pass before entering a loop, allowing that repeated check to be removed.
The correctness requirement also matters: both implementations had to create identical outputs on the selected corpus. That prevents a faster but behaviorally different compressor from counting as an equivalent result and anchors the speed comparison to matching work.
The benchmark is not evidence that all functional programs can approach optimized C. Roc is still immature, roc-deflate received unusually concentrated optimization work, and the test covers one algorithm family on two machines. Streaming performance is also absent. Even with those limits, the experiment shows that safety and functional purity do not automatically impose a large runtime penalty for every systems-oriented workload. Wider testing across mature packages will determine whether the result generalizes beyond DEFLATE.



