Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm surprised by this heated debate regarding GC in this thread. Are you arguing that scripting languages that use reference counting are not garbage collected? PHP used reference counting for a long time (cycle detection only made it into the language in version 5.3 if I trust Wikipedia), it feels odd to consider PHP as not being garbage collected.

For me the underlying technology is not very relevant, what matters is "do I have to worry about exactly when the resource is going to be dropped". I use the resource and when I stop using it it'll probably be deleted soon-ish. At any rate it's not really my problem (at least in a perfect world).

You say "With reference counting [...] you keep track of your allocations and release them when you're done with them" but that's not really true, I don't keep track of anything, the language or library does. I can't really tell by looking at some code in isolation when or how the resource is destroyed. The GC takes care of that.

Some languages like python, Java, Go or PHP have 1st party garbage collection that's active by default and other languages like C, C++, Rust and friends have optional 3rd party GC implemented as libraries (reference counting or otherwise).

I really don't see what's so controversial about this.



PHP is a bad example, it was designed around the idea of the OS doing the cleanup for you when the process exited at the end of the request.


In C, C++, Rust, Swift, &c I can determine how and when references go into or out of scope and get freed.

The defining characteristic of a garbage collected system is an active outside process with priority and control over my code that chooses when to inject bugs (to wit: arbitrary pauses) into my program outside my control.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: