News for hackers. Stuff that matters.
Re:My latest anti-java rant by prodigal_erik on Sunday March 21, 2010 @02:53AM (#1207646)
The weird thing is how many projects resort to reference counting, which is just like GC only far more expensive (now every single p1=p2 requires two checks for null, an atomic increment and decrement, and a conditional branch around a dtor call!) and less reliable.
Re:My latest anti-java rant by chipsy on Sunday March 21, 2010 @04:20AM (#1207705)
It seems to me like the endgame of most memory management problems is static buffers and pools for speed/low fragmentation, and GC for everything else; manual allocations are just too fiddly for most coders to favor them for optimization.

Disclaimer: I've mostly worked in GC environments.

Re:My latest anti-java rant by lars512 on Sunday March 21, 2010 @07:13AM (#1207820)
You say reference counting is far more expensive, but that's only in CPU cycles. Compare Python (reference-counted) and Java (garbage collected), and Java's memory use is 3x greater for similar programs, at least in my experience (also in the computer language benchmark game). Reference counting is a form of garbage collection, it's just eager rather than lazy, and that eagerness pays off in predictably lower memory usage.
Re:My latest anti-java rant by prodigal_erik on Sunday March 21, 2010 @03:43PM (#1208439)
You can save memory by writing a file a byte at a time rather than allocating a buffer. The reason you don't is that it's more efficient to batch that work. Well, the same is true of GC. If you have a million dead objects and a thousand live ones, doing bookkeeping for each dead object is far more expensive (in cycles and bus bandwidth) than just having a copying collector rescue the live objects and then reuse those memory pages en masse.

Once your program's memory footprint is small enough to fit on the machines you're using, making it smaller takes more runtime work but has little benefit.

Re:My latest anti-java rant by jpr on Sunday March 21, 2010 @03:45AM (#1207686)
Also, reference counting can't handle cyclic structures gracefully. Just say no to it.
Re:My latest anti-java rant by InclinedPlane on Sunday March 21, 2010 @06:04AM (#1207767)
Reference counting can also become extremely complex (and error prone) in a multi-threaded environment.