News for hackers. Stuff that matters.
Re:How Scala Compiles to Java by alextgordon on Tuesday September 21, 2010 @08:27AM (#1712330)
In my Java shop, we try to write ultra-efficient code. Avoiding the creation of numerous small objects in critical sections is one of the best ways to achieve that.

I don't know anything about Java, but the Objective-C GC recycles old allocations to avoid this exact problem. For example

    for (int i = 0; i < 10000; i++)
    {
    	Foo *foo = [[Foo alloc] init];
    }
Instead of allocating memory for foo 10000 times, older allocations are kept in a pool and reused for subsequent iterations. So the actual cost of -alloc is just a memset (i.e. nothing). Java's GCs are much more mature, so I would assume they have the same optimisation.

There are no comments on this comment yet.