How close can pure functional programming get to C?
Web page · https://rtfeldman.com/fp-vs-c
First seen by Oriel on .
AI summary
The article benchmarks pure Roc DEFLATE compression against SIMD-tuned C libdeflate, finding median slowdowns of 2.6% on M1 and 8.9% on Ryzen while preserving stronger safety guarantees.
- Across 144 non-streaming Silesia corpus benchmarks with identical outputs, roc-deflate ranged from 18% slower on worst-case inputs to slightly over 18% faster on best cases.
- Roc enforces memory safety, automatic reference counting, bounds checks, function purity, and cross-target determinism without an unsafe escape hatch.
- Roc packages lack arbitrary FFI and build scripts, limiting compromised pure functions to wrong results, crashes, or wasted resources rather than I/O or arbitrary memory access.
- Key optimizations included preserving unique values for opportunistic mutation, hoisting bounds checks outside loops, compile-time lookup tables, and selectively using wrapping arithmetic.
- The author cautions that C retains a higher performance ceiling and that results from this heavily optimized package cannot yet be generalized to other Roc codebases.
#roc #functional programming #compression #performance
Generated by gpt-5.6-sol. Check the original for details.
Metric trends
Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained
Points
Score reported by the source.
- Hacker News: 277, latest observation ; +261 over observed period since
- Lobsters: 51, latest observation ; +50 over observed period since
Comments
Comment count reported by the source.
- Hacker News: 99, latest observation ; +98 over observed period since
- Lobsters: 21, latest observation ; +21 over observed period since
Aliases
| Source | External ID | URL |
|---|---|---|
| Hacker News | 50218195 | https://rtfeldman.com/fp-vs-c Read discussion |
| Lobsters | 7me8wm | https://rtfeldman.com/fp-vs-c Read discussion |