News for hackers. Stuff that matters.
Re:Reference count, don't garbage collect by wizofaus on Saturday July 30, 2022 @10:30PM (#32292606)
That seems a little hard to believe. I can't think of many complex pieces of software I've worked on that didn't have such cycles (e.g. any sort of tree structure where parents need to know about children and children need to know about parents - how does Nim handle that?)
Re:Reference count, don't garbage collect by elcritch on Sunday July 31, 2022 @04:36PM (#32298600)
Nim does allow cycles and the new GC is non-atomic RC + cycle collector.

Though I’ve been hacking on a UI framework written in Nim. Its ui nodes form a tree structure that only tracks parent => child. When it needs the parent info it makes a stack of parents during processing.

Essentially it moves the cycle collector / GC work to extra work during processing. But it’s cheaper since you’re already accessing the memory.

Re:Reference count, don't garbage collect by mbrodersen on Sunday July 31, 2022 @05:55AM (#32294489)
You typically use a weak pointer from child to parent in those situations. So there are no ownership cycles. Languages without garbage collectors (C/C++) pretty much require you to not have ownership cycles or your code will crash during cleanup. Unless you add specific code to detect it and stop it from happening. So I assume you mostly work in GC languages and not C/C++?
Re:Reference count, don't garbage collect by wizofaus on Sunday July 31, 2022 @04:05PM (#32298320)
We were talking about Nim, which is language I know next to nothing about (but very familiar with C/C++, Swift - which has weak pointers, as well as GC languages like JavaScript/Java/C# etc.)