New
Howard Lovatt
howard.lovatt at gmail.com
Mon Mar 29 03:26:28 PDT 2010
I think this is a two sided argument, it has proved difficult to eliminate
object creation because it is tricky to do without gotchas. Take a look at
my point 4 example to see how hard that would be for the compiler to get
right (e.g. when Jobs is in a library and your program GUI doesn't even
compile Jobs).
On 29 March 2010 20:53, Mark Thornton <mthornton at optrak.co.uk> wrote:
> Howard Lovatt wrote:
>
>> 3. The main argument for not using new is that the compiler can 'lift' the
>> lambda to be static if it doesn't access any instance fields or local
>> variables. However this type of optimization has a poor history in Java,
>> think String interning and copying of static fields. In Java a JVM
>> optimization has proven much more successful than a compiler optimization.
>> Hence using new, which would allow a JVM optimization but prevent a
>> compiler
>> optimization, is the best choice.
>>
>>
> On the other hand the JVM optimisations (escape analysis) to reduce heap
> allocation have been "coming soon" for more years than I care to remember.
>
> Mark
>
>
--
-- Howard.
More information about the lambda-dev
mailing list