[Gc] Mentality of c/c++ programmers when it comes to gc

S M Ryan wyrmwif at rawbw.com
Sat Dec 22 10:29:21 PST 2007


> I've been talking with various c/c++ programmers over the globe  
> about the benefits of garbage collection...90% of the people I've  
> talked with are negative to using gc. They propose memory pools or  
> reference counting as the solution to memory management problems.
>
> The amazing thing is that, although I show to them cases where  
> their approach can lead to problems, they still deny its usefulness.
>
> Anyway, that's my rant, I apologize for it. Personally, I can't  
> live any more without garbage collection. It literally transforms c+ 
> + from a language that is complex and difficult to a very simple  
> and elegant language. Many thanks to the people behind the gc.

A lot of the complexity of C++ comes from not using garbage  
collection. The problem arises with objects, nearly always allocated  
on the heap, which are created in an expression and not assigned to  
variable, something like cons(map(car(x)),cdr(x)). If the object is  
not assigned to a variable, then the programmer cannot explicitly  
deallocate it; all of the C++ machinery for finalisers, and calling  
finalizers on a throw, etc, were originally to deal with this problem.

One of the frequent problem using Objective-C in MacOS is releasing a  
reference count too early or not releasing a reference at all,  
leading to all kinds of  bugs and convoluted code. Now that 10.5 has  
garbage collection, the language is actually looking useful.



More information about the Gc mailing list