News for hackers. Stuff that matters.
Re:Highlights of new technologies introduced at WWDC 2021 by jolux on Monday June 07, 2021 @08:08PM (#27429005)
Swift is currently reference counted, which is more or less GC but worse because it’s not tracing/cycle-detecting.
Re:Highlights of new technologies introduced at WWDC 2021 by favorited on Monday June 07, 2021 @08:23PM (#27429144)
Every design decision has tradeoffs. RC has its own significant upsides, like deterministic deallocation and a much lower memory floor for preventing world-pauses during tracing.
Re:Highlights of new technologies introduced at WWDC 2021 by pjmlp on Tuesday June 08, 2021 @09:59AM (#27435306)
And possible stack overflow or freezing applications, when a domino effect of reference counting reaching 0 happens, and dealloc functions weren't properly written.

There is a Herb Sutter talk at CppCon about the downsides of reference counting.

Basically the solution to those problems is to make use of hazardous pointers or deferred destructions on background threads, which are a kind of lightweight tracing GC.

Re:Highlights of new technologies introduced at WWDC 2021 by jolux on Monday June 07, 2021 @09:40PM (#27429689)
How is RC deallocation deterministic?

Besides which I don't want to have to keep track of weak references, at that point I would rather just have a full ownership model: https://github.com/apple/swift/blob/main/docs/OwnershipManif...

Re:Highlights of new technologies introduced at WWDC 2021 by bjustin on Monday June 07, 2021 @10:06PM (#27429852)
I assume the grandparent was talking about how, as soon as the last reference to a refcounted object goes away, the object is deallocated. Pure Swift follows this rule though Objective-C code may not always do this due to things like autorelease pools.
Re:Highlights of new technologies introduced at WWDC 2021 by jolux on Tuesday June 08, 2021 @01:01AM (#27430804)
Sure but that's nothing like deterministic destruction, where I can tell you the order that things will be deallocated just from looking at a block.