News for hackers. Stuff that matters.
Re:Reference count, don't garbage collect by cakoose on Friday July 29, 2022 @10:07PM (#32283677)
Re: "it's well understood reference counting is garbage collection". I think this might just be a terminology thing.

There appear to be two ways the terms are categorized:

1. "reference counting" and "garbage collection" are two types of automatic memory management/reclamation.

2. "reference counting" and "tracing garbage collection" are two types of garbage collection.

I think mbrodersen is using #1.

(Back in the 90s and 2000s I feel like #1 was much more prevalent. But #2 seems to have gained popularity since then. My theory is that whoever started writing the Wikipedia content for this stuff picked #2.)

Re:Reference count, don't garbage collect by bjourne on Saturday July 30, 2022 @04:50AM (#32285309)
I think it's more of an industry vs. academia kind of thing. In the mid-90's before Java was released automatic memory management was mostly unknown to the unwashed masses. So garbage collection became synonymous to whatever Java was doing. However, The Garbage Collection Handbook originally published in 1996 defines garbage collection as: "All garbage collection schemes are based on one of four fundamental approaches; mark-sweep collection, copying collection, mark-compact collection or reference counting." So that's an example of terminology #2.
Re:Reference count, don't garbage collect by tsimionescu on Saturday July 30, 2022 @02:22AM (#32284738)
I think this is actually common in the literature, it has nothing to do with Wikipedia. Consider that Python is commonly described as a GC language, though it has always mostly relied on automatic reference counting to free objects (it does have a tracing GC as well to handle cycles, but I'm not sure if it always did).
Re:Reference count, don't garbage collect by int_19h on Saturday July 30, 2022 @02:54AM (#32284886)
I would argue that what matters is the observable behavior. In Python, regardless of how the actual cleanup is distributed between ARC and GC, the behavior that programmer sees is that all unused memory gets cleaned up eventually. So, it makes sense to group it with languages that provide the same guarantee.
Re:Reference count, don't garbage collect by mbrodersen on Saturday July 30, 2022 @09:46PM (#32292360)
Yep. The compiler generates code that works the same way that an experienced C programmer would hand optimise alloc/free calls and manually keep track of shared data by increasing/reducing a reference counter. There is no separate mark/sweep or whatever step.
Re:Reference count, don't garbage collect by rowanG077 on Friday July 29, 2022 @11:00PM (#32283923)
I never understand why people refer to reference counting as garbage collection. It waters down the term so much it becomes essentially useless. Because under that assumptions basically every language has garbage collection in some shape or form.
Re:Reference count, don't garbage collect by pjmlp on Saturday July 30, 2022 @03:41AM (#32285056)
Because we have studied the literature instead of what a random dude in tells at a coffee

https://gchandbook.org/

https://www.sigplan.org/

https://ieeexplore.ieee.org/Xplore/home.jsp

Re:Reference count, don't garbage collect by rowanG077 on Saturday July 30, 2022 @07:09AM (#32285872)
Nice appeal to authority instead of trying to engage in a meaningful way.
Re:Reference count, don't garbage collect by pjmlp on Saturday July 30, 2022 @11:11AM (#32287389)
When one is open to learning, the best path to enlightenment is to use the same books as the Wizards on the tower of knowledge.
Re:Reference count, don't garbage collect by jstanley on Saturday July 30, 2022 @01:19AM (#32284460)
C doesn't have garbage collection.

Furthermore, pretty much every language has I/O, but that doesn't make the term useless.

Re:Reference count, don't garbage collect by tsimionescu on Saturday July 30, 2022 @02:25AM (#32284750)
They do it because they serve the same purpose, though with different trade-offs.

Note that this mostly reflects automatic reference counting, like you have in Python or Swift, not so much manual reference counting like std::shared_ptr or Rc.