News for hackers. Stuff that matters.
Re:Swift is a more convenient Rust by bad_user on Friday September 06, 2024 @07:40AM (#41465207)
> first language to bring non-GC automatic memory management to the mainstream ... Other languages in this space include Swift

Ugh, “Arc”, aka (automatic) reference counting, is an implementation of GC as well. It may have certain characteristics, like having worse throughput, corner cases, and better predictability/latency characteristics, but it's GC nonetheless. That's not manual memory management. Swift is not a non-GC language.

And that's the big issue that people are missing — Rust tackles some hard problems regarding memory management, and a friendlier alternative exists: garbage collection.

Re:Swift is a more convenient Rust by rcruzeiro on Friday September 06, 2024 @07:53AM (#41465311)
Both ARC and garbage collection are memory management techniques. ARC does not equal garbage collection though. Garbage collection runs at intervals and is triggered by certain signals (memory pressure, etc), pauses all threads and scans for objects that can be deallocated. It is a very different concept than ARC.
Re:Swift is a more convenient Rust by twoodfin on Friday September 06, 2024 @08:07AM (#41465393)
https://courses.cs.washington.edu/courses/cse590p/05au/p50-b...

This paper makes a strong argument that “pure” tracing garbage collection and “rote” reference counting are effectively duals at the opposite ends of a spectrum of implementation choices.

For example, GC’s often optimize differently for young vs. old objects. How do they distinguish these? By “counting” (one bit) their references across one or more traces in a series of sweeps.

Re:Swift is a more convenient Rust by 01HNNWZ0MV43FF on Friday September 06, 2024 @11:22AM (#41467004)
And a hot wheels car is a car, but I would be perplexed to see one offered to me at a car dealership
Re:Swift is a more convenient Rust by Tuna-Fish on Friday September 06, 2024 @08:30AM (#41465546)
ARC is a method of implementing garbage collection, and is discussed as such in academic literature.

What you are equating with "garbage collection" is Mark-Sweep, which is an another way to implement GC, with a very different set of tradeoffs. (Broadly, better throughput at the expense of higher latency.)

Re:Swift is a more convenient Rust by 7jjjjjjj on Friday September 06, 2024 @09:31PM (#41470934)
In common usage everyone understands that GC = tracing GC.
Re:Swift is a more convenient Rust by 112233 on Friday September 06, 2024 @08:47AM (#41465655)
Deleting large hierarchy of objects when the last reference gets decremented also is triggered by a certain signal (reference decrement) and pauses all threads while it collects garbage. There are even tunable GC that become ARC if you set particular parameter to "N=1"
Re:Swift is a more convenient Rust by zozbot234 on Friday September 06, 2024 @09:39AM (#41466104)
I'm not sure that collecting a large hierarchy of objects requires pausing all threads. What can definitely require pausing threads (other than in specialized concurrent collectors) is the tracing step, which relies on some invariants that in simple GC implementations (not the more specialized concurrent ones mentioned earlier) are only ensured at very specific points in the program (known as GC "safepoints").
Re:Swift is a more convenient Rust by 112233 on Friday September 06, 2024 @11:38AM (#41467132)
My bad, thanks for correcting! Of course single thread freeing a lot of heap allocations will not pause other threads by itsel. What I had to write was: calling destructor of an object that in turn calls destructors of other objects (because a large tree of reference counted objects loses last reference to it's root) stops that thread, until all deallocation is done.
Re:Swift is a more convenient Rust by pessimizer on Friday September 06, 2024 @09:14AM (#41465893)
> There are even tunable GC that become ARC if you set particular parameter to "N=1"

You can call a pointer to a value a "one-element static array."

Re:Swift is a more convenient Rust by pessimizer on Friday September 06, 2024 @09:10AM (#41465853)
It's not "automatic" reference counting, it's "atomic" reference counting. And it's not automatic, it's entirely manual and implemented with traits as a fat pointer. Reference counting types in Rust are just defaults that give certain guarantees.

This feels like people arguing that atheism is a kind of religion. Borrow checking and a library of safe default primitives make it so you don't really have to think about memory management; except to the extent that you generally stick to those primitives, and that you have to install the borrow checker into your own head to write Rust comfortably (although the compiler will help.)

Rust doesn't have any garbage collection, but it can just assume how you would want to deal with memory by forcing you to be very specific about when values should be created or destroyed.

Re:Swift is a more convenient Rust by Ontonator on Friday September 06, 2024 @09:27AM (#41465996)
In the context of Swift, ARC is automatic reference counting: https://docs.swift.org/swift-book/documentation/the-swift-pr...