Live data from Hacker News

Linus Torvalds on Garbage Collection (2002)

gcc.gnu.org

11–20 of 207 posts

Re: Linus Torvalds on Garbage Collection (2002)

#11

What he's advocating sounds a lot like how things work in the iOS world, in my experience.

A GC system with explicitly visible reference counts (and immediate freeing) with language support to make it easier to get the refcounts right (things like automatically incrementing the refcounts when passing the object off to others) wouldn't necessarily be painful to use, and would clearly offer all the advantages of just doing it all by hand.

I was wondering how that was different from Cocoa on Objective-C.

See: http://developer.apple.com/library/mac/#documentation/Cocoa/...

Re: Linus Torvalds on Garbage Collection (2002)

#12
post #2

[2002] Though his argument about cache does still hold.

I think it holds for work that's happening close to the metal. If you're working at the level where you're trying to fit all your data in the cache, then GC will get in the way of that. For applications operating at a higher level, or where any calculation that's going on is taking up a trivial amount of CPU time compared to (say) waiting for the user, then the overhead of reference counting (and the mistakes that ar…

Sure. He was talking about the OS level.

In UI scripts or something else running on multiple levels of abstraction, preventing memory leaks and allowing developers to quickly prototype is much more important. Cache performance does not even come into it. It would be crazy to advocate manually managing memory there.

Re: Linus Torvalds on Garbage Collection (2002)

#13
It's 2011, FFS. This kind of mindset is really self defeating in the long term. Sure, hand optimizing is better. Having a gazillion lines of shit legacy code and technical debt to fix because you hand optimized for the 90's, it's not so great. I'll keep my GC and sip a Mohito on the beach, while Linus keeps on fixing Linux's "optimizations" ten years from now.

Re: Linus Torvalds on Garbage Collection (2002)

#14
post #11

What he's advocating sounds a lot like how things work in the iOS world, in my experience.

A GC system with explicitly visible reference counts (and immediate freeing) with language support to make it easier to get the refcounts right (things like automatically incrementing the refcounts when passing the object off to others) wouldn't necessarily be painful to use, and would clearly offer all the advantages of just doing it all by hand. I was wondering how that was different from Cocoa on Objective-C. See:…

The runtime system might not free the memory immediately.

Re: Linus Torvalds on Garbage Collection (2002)

#16

What he's advocating sounds a lot like how things work in the iOS world, in my experience.

In ObjC the retain/release memory management system uses reference counters. When the count hits zero the object is deallocated so that does sound like what Linus is talking about.

Objective C also has the 'new' garbage collection system and there is autorelease which uses a memory pool and releases at some later point.

Re: Linus Torvalds on Garbage Collection (2002)

#17
post #5

Earlier quoted context omitted.

I could see it holding for say Java or C#, but for a single assignment languages like SML or Haskell I don't think it would hold. It seems like changing single assignment to mutation would be one of the first memory related optimizations you would make. While it is easiest to think of that as A1 = A0 + B is a mutation of A, there is nothing that says it should be so limited.

> for a single assignment languages like SML or Haskell I don't think it would hold. It would not have to hold, but I have not heard of any such scheme being implemented.

What about for something like SISAL?

Re: Linus Torvalds on Garbage Collection (2002)

#18

It's 2011, FFS. This kind of mindset is really self defeating in the long term. Sure, hand optimizing is better. Having a gazillion lines of shit legacy code and technical debt to fix because you hand optimized for the 90's, it's not so great. I'll keep my GC and sip a Mohito on the beach, while Linus keeps on fixing Linux's "optimizations" ten years from now.

It's already been ten years since he wrote that.

Re: Linus Torvalds on Garbage Collection (2002)

#19
post #9

I like him mentioning the programmer's mindset associated with GC being a big danger. Some people consider GC a magic bullet and refuse to think about what's happening under the hood. I do not consider that a good habit.

Some people consider it free too which is very painful. Like pretending networks don't have latency.

Re: Linus Torvalds on Garbage Collection (2002)

#20

It's 2011, FFS. This kind of mindset is really self defeating in the long term. Sure, hand optimizing is better. Having a gazillion lines of shit legacy code and technical debt to fix because you hand optimized for the 90's, it's not so great. I'll keep my GC and sip a Mohito on the beach, while Linus keeps on fixing Linux's "optimizations" ten years from now.

The email was written a decade ago.
Post reply on HN