Subscribe. Follow. Stalk.

Wednesday, August 29, 2012

Why I like garbage collection

One of my most favorite features of java is the garbage collection. Being able to create objects on a whim and then simply forgetting about them is the nicest way to program. Gone are the times when you need to clean up the object. Reference counting becomes a thing of the past. Best of all, no more segmentation faults! (this helps me sleep well at night)

Garbage collection means less time on finding bugs and more time working on the internal logic of your application. It means that more code can be completed in less time. Imagine having a person who picks up all the litter you toss on the ground (don't do this) as you walk through the park, the playground, or maybe across the street.

Alas, it's not all perfect. Tight loops and objects that never seem to go out of scope can and will cause memory problems as well. Garbage collection is also an additional overhead for the application, but that is a reasonable trade-off if you don't want leaky code that will grind the entire system to a halt much faster.

For high level programming there's nothing like GC. It's a shame I mainly work on C-based languages nowadays...

No comments:

Post a Comment