Live data from Hacker News

The Garbage Collection Handbook, 2nd Edition

routledge.com

31–40 of 174 posts

Re: The Garbage Collection Handbook, 2nd Edition

#31
post #13

Who would usually need this book?

This book (the 1st edition) gave me exactly what I needed when writing the garbage collector for my programming language.

Besides the great technical content, I found it to be a very enjoyable, readable book.

Re: The Garbage Collection Handbook, 2nd Edition

#33
I feel the need for garbage collection is a language design mis-feature. That is to say, producing garbage is a language design-mis-feature. To quote Bjarne Stroustrup:

> I don't like garbage. I don't like littering. My ideal is to eliminate the > need for a garbage collector by not producing any garbage. That is now > possible.

and it's indeed possible. For example It's become pretty much a non-issue in modern C++: https://stackoverflow.com/a/48046118/1593077 (and C++ is not the only example, it's just a prominent example of a language which almost standardized garbage collection, but eventually did not go that way.)

Re: The Garbage Collection Handbook, 2nd Edition

#35
post #16

Earlier quoted context omitted.

Rust also uses reference counting, probably the worst sort of garbage collection.

Tracing is the worst in terms of performance

Anyone claiming something like this obviously hasn’t dig into GCs. You honestly think that writing into memory at each access, especially atomically is anywhere near the performance of a GC that can do most of its work in parallel and just flip a bit to basically “having deleted” everything no longer accessible?

Re: The Garbage Collection Handbook, 2nd Edition

#36

if you need code to understand garbage collection, there is walkthrough of garbage collector and C code at http://maplant.com/gc.html is really helpful. I tweaked it to work on amd64 and started adding register scanning based on what eatonphil's discord people told me to do. https://github.com/samsquire/garbage-collector It's not fit for any purpose but more of a learning exercise.

Bob Nystrom (of Game Programming Patterns, Crafting Interpreters, and dartfmt fame) also wrote a tutorial implementation[1], of a precise tracing GC as opposed to a conservative one.

Regarding register scanning in a conservative GC, Andreas Kling has made (or at least quoted) the amusing observation[2] that your C runtime already has a primitive to dump all callee-save registers to memory: setjmp(). So all you have to do to scan both registers and stack is to put a jmp_buf onto the stack, setjmp() to it, then scan the stack normally starting from its address.

[1] https://journal.stuffwithstuff.com/2013/12/08/babys-first-ga...

[2] https://youtu.be/IzB6iTeo8kk

Re: The Garbage Collection Handbook, 2nd Edition

#37

I feel the need for garbage collection is a language design mis-feature. That is to say, producing garbage is a language design-mis-feature. To quote Bjarne Stroustrup: > I don't like garbage. I don't like littering. My ideal is to eliminate the > need for a garbage collector by not producing any garbage. That is now > possible. and it's indeed possible. For example It's become pretty much a non-issue in modern C++:…

I wouldn't say it's a non issue. I frequently have to tune allocators to fix heap fragmentation in databases...

Re: The Garbage Collection Handbook, 2nd Edition

#38

if you need code to understand garbage collection, there is walkthrough of garbage collector and C code at http://maplant.com/gc.html is really helpful. I tweaked it to work on amd64 and started adding register scanning based on what eatonphil's discord people told me to do. https://github.com/samsquire/garbage-collector It's not fit for any purpose but more of a learning exercise.

Bob Nystrom (of Game Programming Patterns , Crafting Interpreters , and dartfmt fame) also wrote a tutorial implementation[1], of a precise tracing GC as opposed to a conservative one. Regarding register scanning in a conservative GC, Andreas Kling has made (or at least quoted) the amusing observation[2] that your C runtime already has a primitive to dump all callee-save registers to memory: setjmp(). So all you have…

Implementations are unfortunately allowed to do whatever they want to that jmp_buf, they could xor the contents for all you know. Hopefully no implementation does something silly like that.

Re: The Garbage Collection Handbook, 2nd Edition

#39
post #16
post #14

Rust has left the building

Rust also uses reference counting, probably the worst sort of garbage collection.

The increment/decrement calls only occur on an explicit call to .clone(). No .clone(), no increment/decrement.

You won't see many clones in rust code.

Post reply on HN