Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you had lots of circularly referencing data structures, would it make more sense to choose a garbage-collected language like Go?


Most circular data structures still have some node that is semantically the owner of the whole thing. Having true circular ownership is much rarer.


Closures naturally generate cycles in the data dependency graph. A way out would be to copy the environment of a closure, but that would mean a performance penalty.


Whether and how closures generate cycles, and consequently the best implementation strategy, depends heavily on the language, though. You might have a strictly nested call stack or thunks and continuations; shared mutable environments or immutable copies and moves; copyable environments or linear/affine closure types; boxed closures that can be stored in data structures or unboxed closures that can’t always; first-class or second-class closures; a GC to rely on or none; &c.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: