Thursday, April 18, 2013

Garbage Collection


Programmers who are opposed to garbage collection because manual memory management is easy completely miss the point of GC.

Regardless of whether manual memory management is easy (if you're experienced then it's mostly routine), the greatest strength of GC is not that it makes memory management a bit easier (true in most cases, but non-deterministic deallocation can occasionally complicate things), or even that it's safer and more secure (almost always true), but that it eliminates the need to track which object is responsible for deallocating another object, thus greatly simplifying program structure, increasing brevity of code, and enabling a handful of language features like closures, asynchronous methods, LINQ (C#), etc... that would be much more awkward if not impossible to use.

In short, GC enables programming languages to be more expressive and concise, and the code written in them to be cleaner and simpler, thus greatly improving flexibility, understandability, and maintainability of code. Whether that's worth the tradeoff of reduced performance and occasional added complexity is a matter of application domain and personal preference.

No comments:

Post a Comment