A disclaimer or two for Optional

Brian Goetz brian.goetz at oracle.com
Sun Oct 20 10:08:19 PDT 2013

> I'm astonished how
> much time is wasted on trivial questions about the identity of these
> object references.

(Sadly, same will be true with lambdas too.)

One might be astonished, but one can also learn something from this 
experience, which in hindsight is actually kind of obvious.  For 
"classes" that don't need identity (and the existence of this unneeded 
identity also happens to cripple the VM), we can avoid both the wasted 
time of programmers and wasted performance of programs by *giving users 
a means to express that an abstract data type cannot have an identity.* 
  You can't waste time asking about the identity if there is none.  And 
this unshackles the VM in a serious way.

(We can see this with streams; reducing on an IntStream produces a 
parallel speedup with streams of a few thousand elements; reducing on a 
Stream<Integer> never speeds up at all, because its bound by memory 
bandwidth due to cache thrashing due to boxing.)

More information about the lambda-libs-spec-experts mailing list