5 ms·
Does it have GC? Or does it perhaps use reference counting? Can it detect cyclic references?
by any1 11y ago
Does it have GC? Or does it perhaps use reference counting? Can it detect cyclic references?
- sdegutis 11y agoThe readme seems to suggest it uses reference counting and doesn't do anything special about reference cycles: > Another thing is garbage collection. It seems to be the silver bullet of automatic memory management when it comes to scripting languages, but it has some definitive, serious downsides. Non-deterministic behavior is one, speed is two, memory overhead is three, the difficulty of a decent implementation is four. Reference counting is a simpler approach that is more lightweight, easier to implement, completely deterministic and it has no memory allocation overhead (a program uses only as much memory as needed). Refcounting has its disadvantages too (e. g. memory leaks caused by cyclic references), but I believe that its good properties outweigh them.
- wofo 11y agoHow is reference counting deterministic in a multi-threaded environment?
- H2CO3 11y agoin the sense that an object is deallocated as soon as all pointers to it cease to exist.
- H2CO3 11y agoExactly, Sparkling uses reference counting, and one of the major TODOs is the introduction of weak references in order to address the issue of cycles.
- sdegutis 11y agoImplementing weak references sounds like a feature that will make the language's source code much more complex than the simplicity emphasized in your goals.
- any1 11y agonim has some sort of automatic cycle detection. You might want to look into how they do it. It doesn't hurt to check it out.
- any1 11y agoExcellent! I was hoping that the answer would be that there is no GC.