4 ms·
When people say garbage collection they usually mean a tracing GC. You can twist words and say that shared_ptr means C++ has 'garbage collection' but I doubt a
by leshow 10y ago
When people say garbage collection they usually mean a tracing GC.
You can twist words and say that shared_ptr means C++ has 'garbage collection' but I doubt anyone would agree with you if were were to word it like:
"C++ has a garbage collector"
Ref counting is a form of 'garbage collection' in so far as it is a way to release memory, that's about it. I certainly wouldn't consider Rust's Arc<T> a 'opt in garbage collector'.
- santaclaus 10y ago> When people say garbage collection they usually mean a tracing GC. Wikipedia lists both tracing and reference counting as forms of GC... hell, when interviewing at Microsoft I was asked to describe the two primary families of GC, expecting tracing and ref counting.
- WildUtah 10y agoAnyone can define a bat as a bird because it's an animal with wings that flies. But you'll soon find that isn't a useful conceptual distinction.
- pjmlp 10y agoWell, you are free to disagree with the computer science experts in the field of language design, but it won't make it less true.
- EdHominem 10y agoMore like, you're free to ignore the common-sense suggestion to examine the algorithms used as they pertain to your use case, just because someone once said "In theory these two things are equivalent". But it won't help you once you hit the inevitable edge case. Terminology is useful right up until it isn't. Resting on definitions rather than seeking proper descriptions is a great way to fail spectacularly.
- pjmlp 10y agoNot someone, the main language researchers in the field of memory management. Not a random dude on Internet.
- EdHominem 10y agoYou're doing exactly what I'm talking about, you're trying to show how the authority you consider authoritative is right, not trying to understand how in a very real sense, reference counting also is not garbage collection because it lacks some critical feature from someone else's point of view. If you're right, you're just some guy referencing an authority. Yay you. If you're wrong, you're totally ... all over the point of what someone else is saying. Instead of trying to force us to see how you're right, why not try to see how someone else isn't wrong?
- pjmlp 10y agoIt is not me that is right or wrong, it is the top researchers in the field of programming languages. The papers of computer science, written since the field exists, speak for themselves. One just has to read them.
- braveo 10y agoI agree with you, when people start trying to make these sorts of arguments I like to link the following video from Richard Feynman. https://www.youtube.com/watch?v=45trtAfWhYg https://www.youtube.com/watch?v=45trtAfWhYg
- kibwen 10y agoThe problem is that "garbage collection" as a term seems to have become synonymous with "tracing GC" (or, in other circles, "whatever the JVM does"). I've started using the term "dynamic lifetime determination" to refer to both tracing garbage collection and reference counting (with our without cycle detection, though the distinction matters). The question then is how pervasive a given language makes dynamic lifetime determination. In Java (GC) and Python (RC with CC), it's ubiquitous. In Go (GC with value types) and Swift (RC without CC), it's pervasive. In Rust and C++, it's selective (note that a large C++ codebase with shared_ptr everywhere would, effectively, be garbage-collected (to say nothing of e.g. Boehm)). In contrast, C's automatic storage duration for stack-allocated items ( http://en.cppreference.com/w/cpp/language/storage_duration#Storage_duration http://en.cppreference.com/w/cpp/language/storage_duration#S... ) and Rust's system of ownership for heap-allocated items are things that I'd consider "static lifetime determination".
- marssaxman 10y ago> The problem is that "garbage collection" as a term seems to have become synonymous with "tracing GC" The term has been used that way since I first heard it back in the '80s, so it's probably not a battle worth fighting at this point. Yes, of course, there's a formal sense under which reference counting is just an outlying position within the broader world of garbage collection, but from an engineering point of view, it's a significantly different set of tradeoffs, and reference counting doesn't really qualify as the same thing when you're deciding how to structure your program.