“A paper I quite enjoyed on automatic reference counting for pure, immutable functional programming”
Counting Immutable Beans: Reference Counting Optimized for Purely Functional Programming
为纯函数式语言设计的引用计数,支持原地更新
论文探讨在及早求值的纯函数式语言中用引用计数替代追踪式垃圾回收:精确的引用计数使未共享的值可以被原地销毁和复用,从而减轻全局分配器压力。作者还提出借用引用(borrowed references)与自动推断借用标注的启发式,以减少引用计数更新,并在支持多线程的新编译器中实现,初步结果显示性能有竞争力,常优于现有编译器。
HN 上的人引用它来解释 Lean 4 如何在纯函数式代码里用引用计数做原地更新(例如数组 O(1) 修改),并拿它和其他语言的内存管理思路类比。
HN 书评
推荐在前,同类按时间 · 每篇最多保留 20 条,统计用全部提及“Lean 4 is in the same ballpark as Haskell, Swift, and ML.”
“that details how the runtime makes use of reference counts to do destructive updates in pure code whenever possible.”
“but destructive updates can help with that:”
“I'm sure the details are different, but the general idea, to me, seems the same as the one descibed by Leo and Sebastian in Counting Immutable Beans.”
“So I was able to efficiently use C-style arrays (O(1) update/lookup) while writing functional code. (paper: Counting Immutable Beans )”
看全部 8 条 →
- Counting Immutable Beans: Reference Counting for Purely Functional Programming ↗matt_d · 2019-08-22 · 2 分