News for hackers. Stuff that matters.
Re:Java 21: What’s New? by kaba0 on Thursday August 10, 2023 @04:01AM (#37073312)
You missed out on Java’s records that solve your gripe with get/set.
Re:Java 21: What’s New? by cutler on Thursday August 10, 2023 @06:31AM (#37074278)
Records are not the same as classes.
Re:Java 21: What’s New? by kaba0 on Thursday August 10, 2023 @07:33AM (#37074771)
They are not, but if you need strictly a class for strictly storing data, records are superior in every way. Unfortunately some tools still want POJOs, but most (eg. Converting to json) do work with records.
Re:Java 21: What’s New? by nogridbag on Thursday August 10, 2023 @09:38AM (#37076025)
Disagree with that, but please provide a counterpoint. I've using Java 17 for a large project and I was really excited to use records. I have not found any practical use case for them outside of one or two instances in a project with 2 years of development.

Storing data is also where I thought records would be a good use case. But in the real world data is not Point(x,y). If you have more than 3 or 4 fields in your record, that's simply not going to work. I thought the rest of the industry decided over a decade ago that using positional properties (e.g. new MyRecord(a,b,c,d,e,f,g)) to initialize an object was a bad idea. I think Rich Hickey gave a whole talk on that subject. If there's a future plan to be able to create records using named props, e.g. new MyRecord([firstName: "Bob"]), then I would reconsider my opinion.

Re:Java 21: What’s New? by kaba0 on Thursday August 10, 2023 @10:08AM (#37076357)
Re:Java 21: What’s New? by nogridbag on Thursday August 10, 2023 @06:38PM (#37082627)
Thanks for sharing. It looks interesting.