re: All the ways to collect garbage VIEW POST

FULL DISCUSSION
 

Great easy to read summary of these types of Garbage Collection, look forward to the sequel.

Some languages I've used:

  • C++ - programmer is responsible. With great power comes great responsibility.
  • Java - fancy mark sweep (parallel, generational, compacting?)
  • C# - fancy mark sweep (parallel, generational, compacting)
  • Python - reference counting (mark sweep for reference cycles).
  • Lisp - mark sweep typically (eg. Emacs Lisp)

I'm also a programming language design/implementation enthusiast and have written several (non-published) languages. Typically I prefer stop-the-world mark/sweep because it's the least intrusive and simplest to implement for compile languages. For interpreted languages, reference counting can be easier to start with. Either way you can refine these later when it becomes an issue (it will do if you want to get serious).

A very interesting language to look at is Rust which puts the responsibility of memory management in the hands of the programmer, but really enforces this through life time annotations. Initially mind blowing, but it's essentially the power of something like C++ without so much danger (though at the cost of hurting your brain and hands more).

If anyone wishes to read more (or too much perhaps), I can recommend this book which I have read:

Garbage Collection Algorithms - 1996

Or it's newer sequel, which I have not read (yet):

Garbage Collection Handbook - 2011

See also Wikipedia - Garbage Collection which is a good jumping off point to find out more information.

For most programmers I recommend at least having a high level understanding of the garbage collection used by each language, and be aware of the trade-offs.

 

Telepathy!

I am working on Rust nowadays to analyze its performance quantitatively and whether the feature of "Ownership" is worth sacrificing performance!

Thanks for these awesome links !!

 
code of conduct - report abuse