New candidate JEP: 401: Primitive Objects (Preview)
Brian Goetz
brian.goetz at oracle.com
Sat Mar 20 13:04:00 UTC 2021
> The messaging I see is:
> Optional = old, slow, memory-hop
> Optional.val = new, fast, flattened
This is a somewhat cartoonish simplification of the messaging.
Simplifications are great for understanding the broad goals, and as
cartoonish simplifications go, it's accurate enough, but we should be
aware of when those simplifications start to get in the way. Migration
is a a more advanced use case, and requires a more refined perspective,
because you're trading off more things and making finer sub-distinctions
within the cost model.
This illustrates one of the hazards of our approach; to justify such a
big change to the platform, we have to at least have a credible story to
fill in all the corner cases, but what then invariably happens is that
minority features invariably command much more attention than they
should. (This is in part because, if you've not spent thousands of
hours swimming in this, it's not yet obvious what is tail and what is
dog, and also, the tail is usually where the ugliest syntax lies, which
invariably attracts our attention.)
> and as such, I would naturally use Optional.val in the API methods.
I think you need to consider that your intuitions of what you would
"naturally" do are not yet informed by any actual experience with this
programming model, and perhaps you should ascribe a little less
confidence to what you would "naturally" do when confronted with a more
subtle challenge like this.
More inquiry, less certainty.
On 3/20/2021 4:40 AM, Stephen Colebourne wrote:
> On Sat, 20 Mar 2021 at 02:02, Brian Goetz <brian.goetz at oracle.com> wrote:
>>> When reading the proposal I see that in the feature we will get code like:
>>>
>>> Optional.val<User> findUser(...)
>> This is not what we anticipate. I would expect that for migrated types,
>> public interfaces would continue to use Optional (alias for
>> Optional.ref); we'd mostly only see Optional.val inside of private
>> implementation, where things actually hit the heap.
> Why do you anticipate that?
>
> The messaging I see is:
> Optional = old, slow, memory-hop
> Optional.val = new, fast, flattened
> and as such, I would naturally use Optional.val in the API methods.
>
> Stephen
More information about the valhalla-dev
mailing list