3 ms·
How do you avoid heap allocations in Haskell? Automated reference counting is technically a GC, but a kind of GC that can be enabled only for a subset of objec
by pkolaczk 7y ago
How do you avoid heap allocations in Haskell?
Automated reference counting is technically a GC, but a kind of GC that can be enabled only for a subset of objects. In languages which force GC on everything (even reference counted GC) the incentive to provide abstractions that work without GC are much weaker. It is just hard to opt-out from GC once you have it and once all your stdlib relies on it. I thing D learned it the hard way.
- pjmlp 7y agoStack and register allocation in Haskell is under compiler control via escape analysis, however you can allocate native heap outside GC via mallocBytes/allocaBytes/free, and if they get integrated into mainstream GHC, linear types. Besides, plenty of GC enabled languages offer the option to stack allocate, static global allocations, or native heap. Some examples, including languages that for whatever reason failed on the mainstream market. D, C#, Swift, Oberon, Oberon-2, Active Oberon, Component Pascal, Mesa/Cedar, Sing#, System C#, Nim, Modula-2+, Modula-3, VB, Xojo, C++ (via C++/CLI, C++/CX and Unreal C++), Common Lisp.
- pron 7y agoYou might want to look at the new RTSJ spec [1] for how memory is divided into a GC heap and nested arena-collected regions in real-time Java. [1]: https://www.aicas.com/cms/en/rtsj https://www.aicas.com/cms/en/rtsj
- pjmlp 7y agoAs addendum to my comment, D learned the hard way how not having a focused goal or godfather company hurts adoption. Go and .NET are doing quite alright.