When will Java go mainstream like Python?

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Wed Feb 24 20:05:30 EST 2010


In message <op.u8nfpex8y5e8ok at laptopwanja>, Wanja Gayk wrote:

> Reference counting is about the worst technique for garbage collection.

It avoids the need for garbage collection. It means I can write things like

    contents = open(filename, "r").read()

and know the file object will be immediately closed after its contents are 
returned.

It also means I don’t have to predefine how much memory my program will use. 
A garbage collector will only kick in when the app runs low on memory. On a 
system with dynamic memory allocation, that will not happen until the entire 
system runs low on memory, unless you limit the app to some fixed amount. 
Which is an antiquated way of doing things.

And then there’s caching. Modern CPUs owe most of their speed to assumptions 
that programs will obey locality of reference. Pointer-chasing is a cache-
hostile activity. Garbage collection involves a lot of pointer-chasing, 
particularly of dead objects that have long since been flushed from the 
cache, compared with reference counting of recently-accessed objects. 
Therefore garbage collection loses performance.



More information about the Python-list mailing list