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

The other recurring example for me was OpenGL resources like textures (this was in ObjC). Again, it turned out not to work so while once I got into more complicated examples, because of ordering issues: my GLWindow instance would get deallocated, and my refcounted GLTexture class would then get finalized after the underlying CGLContext was gone, or just not the active context. I started coming up with more elaborate schemes to deal with it but then it no longer felt elegant.

There is one other aspect of RC systems that I have come to appreciate but never seen anyone else write about: they play well with each other. It's fairly trivial to create foreign object wrappers for python and objective-c in both directions, that each call the appropriate refcount ops of the foreign system. You can then have allocated data structures referring back and forth across the language bridges and when you abandon the root, everything deallocates properly and deterministically in both runtimes. I do not have much experience with GC runtimes and their FFIs but from what I've read I suspect this might be trickier to reason about. This is an obscure point, but one that I did find interesting in terms of language interop.



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

Search: