Re:Chris Lattner on garbage collection vs. Automatic Referen...
by hmlongco on Tuesday April 26, 2022 @06:27PM
(#31173956)
"No doubt straight up ARC with refcounting bumps on every function call,etc..."
Yeah, but in Swift you don't do that. From what I'm told, the compiler's static analysis has gotten a lot smarter in determining when a ref-count bump is needed, and the increased use of struct-based value types in the language leads more and more to situations where a refcount bump isn't needed at all since there's no object reference in the first place.
Re:Chris Lattner on garbage collection vs. Automatic Referen...
by pizlonator on Sunday April 24, 2022 @09:59AM
(#31144047)
This “cheating” has been going on in GC’d languages for decades. Java, JavaScript, and probably other language implementations have what they call “escape analysis”.
Re:Chris Lattner on garbage collection vs. Automatic Referen...
by adgjlsfhk1 on Sunday April 24, 2022 @02:13AM
(#31141692)
note that GCs are starting to cheat too. Julia (for example) is in the process of implementing compile time escape analysis which will be used to (among other things) remove allocations as long as the compiler can prove you won't notice.
Re:Chris Lattner on garbage collection vs. Automatic Referen...
by hayley-patton on Sunday April 24, 2022 @03:32AM
(#31141999)
Java, Go and JavaScript implementations do escape analysis already.
Re:Chris Lattner on garbage collection vs. Automatic Referen...
by adgjlsfhk1 on Sunday April 24, 2022 @11:42AM
(#31145122)
cool! (I gave the example of Julia, but because it's the best GC implementation (it's not), but because it's the implementation I know).
But that isn't how I read what Lattner said here, and I've been thinking similar things. Essentially with ARC the goal is to cheat (to be fair with tracing GC it is as well, just in different ways). And you cheat by implementing an ownership/borrow collector type system behind the scenes for getting rid of the need for RC on most of your objects. Once you do that, you have GC competing with stack allocation + some malloc/free scattered in. It becomes a much more interesting fight.