Re:Ask HN: Why do langs with alleged “automatic memory manag...
by ErotemeObelus on Thursday July 18, 2019 @02:13PM
(#20472490)
What is even the point of garbage collection? By the time you manage all the resources of a 100k line application you're going to have to do as much work as if you wrote it in C.
Re:Ask HN: Why do langs with alleged “automatic memory manag...
by jarjarbinks455 on Thursday July 18, 2019 @02:23PM
(#20472601)
Well the point of gc is to allow the algorithm to focus on the problem domain. and not worry about mechanical implementation details of a computer. Everything has a trade off. An obvious win still must pay a cost elsewhere. In the case of GC it's simply not a good trade off for many resources. Sometimes it cannot be used even if you were willing to accept a trade.
Re:Ask HN: Why do langs with alleged “automatic memory manag...
by ErotemeObelus on Thursday July 18, 2019 @02:33PM
(#20472698)
Managing resources by hand is managing the mechanical implementation details of a computer. So in order to have garbage collection that manages more than just a sliver of memory so small that it counts as a rounding error by the same you get to the size of real world projects, you need a custom operating system and possibly even custom hardware too.
Re:Ask HN: Why do langs with alleged “automatic memory manag...
by AnimalMuppet on Thursday July 18, 2019 @06:12PM
(#20474432)
Your statement is false for many real world projects. (For some, you are correct. Those projects should not be written in a garbage-collected language, or should be written to run on a custom OS and custom hardware.)
Re:Ask HN: Why do langs with alleged “automatic memory manag...
by erik_seaberg on Saturday July 20, 2019 @01:07AM
(#20484284)
When GC'd objects represent resources like open connections and files, use-after-free safely and reliably raises an exception to handle. Without GC, use-after-free on pretty much any object is so catastrophic that even correct code starts doing unpredictable things.
But it's rarely a good idea to piggyback. Most resources are much more limited or time sensitive than memory. So you should free them immediately.
Even when your resource -is- memory it sometimes is a very very very bad idea to free via garbage collection.