Garbage Collection - Why?

Pages: 1234
What bothers me is that most if not all GC languages give you no choice.
Last edited on
Most OSes also don't give you any choice how they manage memory or assign CPUs to processes or threads. And tradeoffs are there, too. In fact, any modern OS like Linux/Windows/OS X/Android etc. can pause your program for arbitrary long time or do some other crazy things with your memory (Windows is particularly lucky at moving *needed* things onto swap and bringing *unneeded* things into memory), and you don't have great control over it. Moreover, the OS also doesn't have control over everything, e.g. lots of stuff is up to the CPU microcode.

Why aren't you whining about why CPU vendors don't give you tools to control cache eviction policies? It might affect performance probably much more than switching from GC to your custom C++ pool allocator.

In that light lack of choice GC vs your own dynamic memory management is not that huge limitation. Most applications don't spend more than 1-2% of time doing GC, so there is not much to optimize.
Last edited on
I find it highly unlikely that petitioning companies to make optimizations in their OSes or chips will have any effect. With a language, you're generally much more likely to get the attention of a passionate expert.

No one solution works for all problems; no one language works for all scenarios. But it's a real pain when such a useful language like Java has to be thrown out the window because of limitations that make it unacceptable to use.

(Don't give me the whole "fixed in Scala" stuff. Obviously if another language "fixed" it, then it is broken in Java. I really like Java but I just feel like it is a language of huge missed opportunity.)

I also feel discomfort with C++; many of the extraordinary performance advantages over C only happen when you inline functions and templates and let the compiler optimize the code. If you use an idiom like PIMPL, you're screwed out of wonderful performance gain. If you inline everything, you risk all sorts of problems. Then there's the whole problem of two C++ binaries having to be compiled in exactly the same circumstances in order to work together properly without crashing due to differing compiler implementations.

For many languages, it also feels cumbersome to have to use so many design patterns, idioms, and practices that were designed to prevent problems that arise from language design flaws that won't be fixed.

I like being enthusiastic but things just seem all out of whack in the programming universe. I'm just ranting here, I don't intend to get responses or arguments from people - just explaining everything that annoys me.
Last edited on
I think part of the reason that some programmers are wary of GC is because they are either echoing the words of an old hat or they are an old hat who remembers a time when giving resources to GC to save them on maintenance was ludicrous and could only serve to hinder performance in anything non trivial.
+1
Just to be clear, I'm not against GC, I'm just against forcing GC use in languages. There are many practical applications of GC, but there are many languages that I would like to better use without it. Mainly because I don't do anything that works better with GC...
Last edited on
closed account (o1vk4iN6)
+1
starting to look like stackoverflow in here.
I think the record is above 40 pages.
Topic archived. No new replies allowed.
Pages: 1234