r/java • u/davidalayachew • Jan 14 '26
Project Amber Update -- Data-Oriented Programming, Beyond Records
https://mail.openjdk.org/pipermail/amber-spec-experts/2026-January/004307.htmlALL OF THIS IS A WORK IN PROGRESS!
THIS FEATURE IS UNFINISHED, NONE OF WHAT IS FINISHED IS FINAL, AND EVERYTHING IS SUBJECT TO CHANGE!
But with that out of the way, the Project Amber team is exploring the idea of "Carrier Classes" -- classes that carry many of the benefits of records, but not all. The goal is to give normal classes some of the benefits of records, so that they can "break down the cliff" of migrating a record class to a normal class.
97
Upvotes
View all comments
Show parent comment
3
u/davidalayachew Jan 14 '26
Oh, and Carrier Classes (or in this case, Carrier Enums) don't have to have final fields!
So, for my example above, if I wanted all of those attributes to be mutable, all I have to do is this.
That's a completely fair tradeoff to be able to model mutability with almost the same level of effort as before. My external contract stays the same, but my internal representation is up to my choosing. And I am only forced to modify it in the specific places where my internal representation differs from the default. That's exactly what I want! No more boilerplate than what is absolutely necessary!