3 ms·
Yep. The language doesnt allow data cycles. Nobody ever complained about that or even noticed it.
by mbrodersen 4y ago
Yep. The language doesnt allow data cycles. Nobody ever complained about that or even noticed it.
- wizofaus 4y agoThat 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?)
- mbrodersen 4y agoYou 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++?
- wizofaus 4y agoWe 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.)
- elcritch 4y agoNim 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.
- elcritch 4y agoNot sure what you mean but Nim allows data cycles. I just prefer to write cycle free code when I can and turn off the cycle collector. Though Nim’s cycle collector performs well and does some tricks using the RCs.