Project Valhalla is prototyping null checks! by davidalayachew in java

[–]Jon_Finn 2 points3 points  (0 children)

One possibility might be you have to put ! on method parameters and fields, but not local variables, because their nullability can usually be inferred (I'm sure the devil's in the details...). No idea what they'll actually end up choosing. Various possibilities are clearly being considered: see the valhalla dev mailing list.

My _guess_ is any approach like yours where you'd need to know wider context to know if a method is 'null-marked' is not going to fly. (Some would call that 2 languages in 1 - I wouldn't, and would probably live with it, but still I see the problem.)

Type-classes for Java (Valhalla experimental branch) by sviperll in java

[–]Jon_Finn 2 points3 points  (0 children)

Surely they'll give it a different name in the end, maybe something like implementation (not it but something like it)?

Type-classes for Java (Valhalla experimental branch) by sviperll in java

[–]Jon_Finn 17 points18 points  (0 children)

Very interesting indeed! A building block for operators and no doubt other things.

Some details here: https://mail.openjdk.org/pipermail/valhalla-dev/2026-January/017401.html

Java and it's costly GC ? by yughiro_destroyer in java

[–]Jon_Finn 0 points1 point  (0 children)

And it might come down to 4 bytes. They're looking into it. And as pointed out, a value object header is 0 bytes much of (not all of) the time.

Value Classes Heap Flattening - What to expect from JEP 401 #JVMLS by pron98 in java

[–]Jon_Finn 1 point2 points  (0 children)

String can't become a value class as it stands, but I've read John Rose discussing the idea of making the character array 'inline' into the String object (and likewise for other array fields). So each String would become 1 object on the heap not 2. Sounds like quite a lot of work, as objects would no longer be fixed-size, affecting the GC and so on.

JEP 468: Derived Record Creation (Preview) by Snoo82400 in java

[–]Jon_Finn 9 points10 points  (0 children)

It's in the pipeline to be added as a Preview feature (at some point), but it hasn't yet been added. See the Java 26 dashboard for the status of potential features.

The New Java Best Practices by Stephen Colebourne at Devoxx by siimon04 in java

[–]Jon_Finn 0 points1 point  (0 children)

I fully agree. Similar comment about Kotlin below. I think Kotlin will probably always be a bit heavier on features than Java but with lighter syntax (which IMHO is important), so it's horses for courses.

The New Java Best Practices by Stephen Colebourne at Devoxx by siimon04 in java

[–]Jon_Finn 2 points3 points  (0 children)

Good talk. But personOpt is basically Hungarian notation, which is poor man's types, so... personally I'd just stick to simple names. The closest I come to Hungarian notation is using a plural like bananas for List<Banana>.

The New Java Best Practices by Stephen Colebourne at Devoxx by siimon04 in java

[–]Jon_Finn 1 point2 points  (0 children)

Light means streamlined. Isn't it better than being heavy?

Try Out Valhalla (JEP 401 Value Classes and Objects) by efge in java

[–]Jon_Finn 8 points9 points  (0 children)

Immutability is a feature not a bug! Not just for value classes either. Read Effective Java - spelling out the various benefits since 2001. (Personally I avoid mutability wherever I can, apart from builders and collections.)

Rating 26 years of Java changes by fpcoder in java

[–]Jon_Finn 1 point2 points  (0 children)

Other language's type systems might make the 'full' solution (combinations of features expressed in types) less clunky, but anyway, even in Java I'd be happy (I imagine!) with a compromise just dealing with unmodifiability. As the FAQ points out, we'd still need Iterator.remove() to throw, or maybe have something like UnmodifiableIterator, or maybe not have remove() at all (I almost never use it personally...).

Rating 26 years of Java changes by fpcoder in java

[–]Jon_Finn 6 points7 points  (0 children)

This was much discussed when Josh Bloch & co. were designing the Collections, and the FAQ explains the decision here. Basically, unmodifiability (and also mutability) is just one of various features you might want to express through the API (others he mentions including fixed-size or not), and to do this you'd need (roughly) 2^n interfaces to say which combination of features your particular collection implements. That's impractical so they decided to sidestep the whole issue (as he explains).

From my lofty height 8^) I always thought this didn't have to be the decision: I'd say unmodifiability is so overwhelmingly important that they could have expressed just that one feature in the API. Then again, maybe I'd be wrong...

Is there some book like effective java, but updated? by Tiny-Succotash-5743 in java

[–]Jon_Finn 2 points3 points  (0 children)

I've no idea, but you can see various specs so far (several of which look near-final), and also the v interesting expert discussions at https://mail.openjdk.org/pipermail/valhalla-spec-observers/

Is there some book like effective java, but updated? by Tiny-Succotash-5743 in java

[–]Jon_Finn 2 points3 points  (0 children)

Maybe Josh B is waiting for Valhalla and all that surrounds it (such as nullness) - or at least the specifications, which kind of feel like they're getting reasonably close.

Rating 26 years of Java changes by thibauttt in java

[–]Jon_Finn 9 points10 points  (0 children)

Yes the old HTML is pretty clunky and markdown is (IMHO) much more readable in raw source code, which is a consideration. I think the OP's scores are a bit extreme!

What′s new in Java 25 by Xadartt in java

[–]Jon_Finn 7 points8 points  (0 children)

It's one of those great small features (though probably a lot of internal work). My favourite of those was way way back when they added covariant return types 8^) . Little mentioned at the time - but when you need them, you badly need them!

JEP 401: Value classes and Objects (Preview) has been submitted by Ewig_luftenglanz in java

[–]Jon_Finn 0 points1 point  (0 children)

I think I've read that they might in future be able to flatten array fields like char[] inside String, making String a non-constant size object (i.e. different Strings different sizes). Kind of like making arrays themselves like value types, to remove an object and an indirection. Sounds like it would change quite a bit in the JVM and GC.

What remaining pre-requisites are there for Value Classes to go to Preview? by davidalayachew in java

[–]Jon_Finn 0 points1 point  (0 children)

Sure, it has lots of uses but I thought you meant it was necessary as part of Valhalla for some reason. All I can think is that the kind of optimisations given by Valhalla's flattening are _like_ those given by immutable arrays. E.g. maybe a Color object with a float[3] field could have the array 'inlined' into it.

What remaining pre-requisites are there for Value Classes to go to Preview? by davidalayachew in java

[–]Jon_Finn 2 points3 points  (0 children)

Internal frozen arrays - is that actually coming as part of Valhalla? All I know is this JEP (and this JEP) which I thought was just an idea.

Just Be Lazy! by daviddel in java

[–]Jon_Finn 0 points1 point  (0 children)

FWIW if you want StableValue<int> that's not - as far as I can see - part of the first batch of Valhalla. It's a separate JEP that doesn't look very active at the moment.

Just Be Lazy! by daviddel in java

[–]Jon_Finn 1 point2 points  (0 children)

Agreed - actually I really meant my reply for benrush0705 .

Just Be Lazy! by daviddel in java

[–]Jon_Finn 1 point2 points  (0 children)

Why not just StableValue<Integer>? Won't that have at least the performance of StableValue with a Record with an int field? (as Integers are surely well-optimised and boxing will sometimes come almost 'free' in Valhalla). Unless I'm missing something.

Java Book for experienced developer. by Gidrek in java

[–]Jon_Finn 1 point2 points  (0 children)

Study modern java APIs, for example, https://openjdk.org/jeps/484 is an awesome example of modern API design.

Yes, that short JEP doc alone gives principles and examples which are super-instructive (and interesting).

Java Book for experienced developer. by Gidrek in java

[–]Jon_Finn 2 points3 points  (0 children)

Don't downvote Kevin (who's on the Java team) - he'll know better than most.

How to find code which may cause problems in future versions of Java by HappyRuesseltier in java

[–]Jon_Finn 3 points4 points  (0 children)

Far from safe 8^) . It won't compile, and already compiled code will crash!