For everything else, there is garbage collection.
Garbage Collection is Wrong
11–20 of 111 posts
Re: Garbage Collection is Wrong
#12In modern C++, using new or delete in your code is wrong. It's not done. Nobody writes code like that anymore in C++. It's been quite a while since I wrote any significant C++ code, but this statement seems wrong. Is this really "state of the art" for C++?
Re: Garbage Collection is Wrong
#13Re: Garbage Collection is Wrong
#141. plenty of garbage collectors do not pause all threads or wait for memory to be full.
2. you CAN ask for gc anytime you want in java and in C# (you need not wait for it to happen)
3. new and delete are still integral to C++ (check out any large codebase, like llvm)
Re: Garbage Collection is Wrong
#15In modern C++, using new or delete in your code is wrong. It's not done. Nobody writes code like that anymore in C++. It's been quite a while since I wrote any significant C++ code, but this statement seems wrong. Is this really "state of the art" for C++?
Seeing new and delete has very heavy code smell and can be avoided 99% of the time.
Re: Garbage Collection is Wrong
#16The vast majority of resources are short-lived and don't create cycles. Our garbage collections "systems" should be designed for this case.
Cycles are a special case required for few data structures. They are not the norm and we shouldn't ship a huge heaping mess of a garbage collection system and make everything else slower to account for this rarely used special case.
Anyway people programming today shouldn't be thinking in terms of pointers and references. We should be thinking in terms of VALUES. Finite values have no cycles! The Haskell and C++ community have already embraced this, everyone else is still catching up.
Yet another reason why Java is a horrible language holding people back and the JVM is basically a hamster wheel keeping itself busy.
Re: Garbage Collection is Wrong
#17In modern C++, using new or delete in your code is wrong. It's not done. Nobody writes code like that anymore in C++. It's been quite a while since I wrote any significant C++ code, but this statement seems wrong. Is this really "state of the art" for C++?
Re: Garbage Collection is Wrong
#18Yes, in some scenarios you can associate the lifetime of a resource with the lifetime of a storage location, but this simply does not work in all cases, probably only in a small fraction of all cases. And then? How do you handle resources that have no single obvious owner? How do you determine if the resource is still in use when you are done with it in one place? You implement some kind of reference counting? You ke…
In what cases is this not possible? I model the resource as an object and that object has a memory location.
(Yes, in a non-deterministic GC, you can't do this for expensive resources, but that's a problem of GCs, not an in-principle problem).
EDIT: I am guessing the parent actually meant "associate the life time of a resource with the life time of a single, non-/never-shared storage location". The statement as written is one I have seen proponents of non-deterministic GCs make.
Re: Garbage Collection is Wrong
#19not even sure where to start... 1. plenty of garbage collectors do not pause all threads or wait for memory to be full. 2. you CAN ask for gc anytime you want in java and in C# (you need not wait for it to happen) 3. new and delete are still integral to C++ (check out any large codebase, like llvm)
As for point 3, just because it's in use, doesn't mean it's correct. With the introduction of unique_ptr, most uses of new and delete can and should be factored out.
Re: Garbage Collection is Wrong
#20In modern C++, using new or delete in your code is wrong. It's not done. Nobody writes code like that anymore in C++. It's been quite a while since I wrote any significant C++ code, but this statement seems wrong. Is this really "state of the art" for C++?