Live data from Hacker News

Linus Torvalds on Garbage Collection (2002)

gcc.gnu.org

1–10 of 207 posts

Re: Linus Torvalds on Garbage Collection (2002)

#3
post #2

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

I think his opinion might not have changed. In his latest "C++ sucks" rant in that "why is git written in C" thread he points out not having GC as being one of the detriments of C++.

Re: Linus Torvalds on Garbage Collection (2002)

#4
post #2

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

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.

Re: Linus Torvalds on Garbage Collection (2002)

#5
post #2

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

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.

Re: Linus Torvalds on Garbage Collection (2002)

#6
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 are associated with that) is probably not worth it.

Re: Linus Torvalds on Garbage Collection (2002)

#10
post #8

Might be worth mentioning Tcl in this context, as it uses reference counting for the GC [1]. It also doesn't allow circular data structures, which are quit hard to implement if all you have are strings anyway. [1]: http://wiki.tcl.tk/3096

Perl also uses reference counting, and cyclical data structures cause memory leaks unless you explicitly decrease the reference count with the weaken function from Scalar::Util.
Post reply on HN