Better HN
topnewbestaskshowjobs
Log inSign up

joe_mwangi

96 karma · joined Aug 13, 2025 (1y ago) · 52 submissions

Submissions

comment 1mo ago · link · parent

But what example would you have to demonstrate it's more powerful? As a matter of fact, Kotlin smart-cast approach can't tolerate mutability because it can't guarantee safety, yet Java guarantees.

comment 1mo ago · link · parent

But they should use reasoning first.

comment 1mo ago · link · parent

Wait, what do you mean Kotlin smart-casting is more powerful than pattern matching? Like what example?

comment 2mo ago · link · parent

Trust me. That's a common argument used when java introduces new features. Wait you see the same argument once value classes come to jdk 28.

comment 2mo ago · link · parent

Yes.. lol. The biggest argument now is Kotlin having nullness by default in the language. Just check around the comment section. Now java is planning to have them which will further help jvm to optimise for performance. Not sure what the next argument will be after.

comment 2mo ago · link · parent

Really? I don't thinks so. There is a reason JEP 539 is in preview. There is a reason internal annotations exists in current valhalla jdk prototype and upcoming java 28 such as @jdk.internal.vm.annotation.NullRestricted, @jdk.internal.value.ValueClass.newNullRestrictedNonAtomicArray. Also, there is a reason value classes are allowed to be null. This is because nullness types will be a key factor to the java language.

comment 2mo ago · link · parent

Once it gets nullness types, hackernews is gonna explode!

comment 2mo ago · link · parent

Typeclasses caught me by surprise. Smart move by the java team.

comment 3mo ago · link · parent

Also, future specialisation if it is introduced, it will enable the JIT to get enough information to ensure <T> becomes stored in cpu registeres or enable <T[]> to be flattened in memory.

comment 3mo ago · link · parent

Yeaaah. They are going to introduce approaches for the programmer to decide if tearability is allowed or not. Already there are internal annotations for fields and types to enable it that probably will become a language feature in future.

comment 3mo ago · link · parent

They are researching to have immutable arrays. Also multifields (stack allocated arrays as fields in value classes). So, there is a possibility.

comment 4mo ago · link · parent

I've done some tests with current value classes in latest prototype with full optimisation through annotation. Apparently, everything was being compiled to assembly code with no gc calls. It seems this old school ideology of slow java is about to end in near future. I'm actually intrigued how it will compete with Rust which can't optimise code further while running, while JVM JIT has more info which it could aggressively further optimise, especially hot paths.

comment 4mo ago · link · parent

Also, this will be used for future null-restricted types.

comment 5mo ago · link · parent

Better late than never.

comment 5mo ago · link · parent

This time, 30mb.

comment 5mo ago · link · parent

Yup. By design, value classes will use cpu registers as a 1st priority instead.

comment 5mo ago · link · parent

Until they implement member patterns. https://openjdk.org/projects/amber/design-notes/patterns/tow...

comment 5mo ago · link · parent

> yet But up the comment section, someone thinks they won't be there 'in the future'

comment 5mo ago · link · parent

And I notice, people aren't aware more things are being planned for. For example, the carrier classes being proposed, they will separate state description with state representation and this is where value classes will shine syntactically.

comment 5mo ago · link · parent

And the only syntax change is adding 'value'.

comment 5mo ago · link · parent

Since they plan to have null-restricted types, then I don't see any issue.

comment 5mo ago · link · parent

But with null-restricted types, Integer! and int has no difference semantically and representation. They plan to introduce null-restricted types in future.

comment 5mo ago · link · parent

This is awesome. First step to an interesting direction of the language.

comment 6mo ago · link · parent

More reasons why java value classes will be a game changer.

comment 6mo ago · link · parent

Java’s planned approach is more like typeclass-style interfaces than unrestricted operator overloading. Types opt into core-defined operator contracts, rather than every library inventing arbitrary meanings for symbols.

comment 6mo ago · link · parent

Damn. You're old school. Java’s answer is virtual threads, not async/await. The idea is that most server-side IO can stay in direct style enabling blocking-looking code, cheap virtual threads underneath. So you don’t split the whole codebase into sync vs async functions just to avoid blocking OS threads. CompletableFuture and reactive APIs still exist, but Loom reduces the need to use them as the default application model. You can now launch millions of virtual threads to do IO.

comment 6mo ago · link · parent

Notice you point out features that were easy to add during the beginning where there was no concern of backward compatibility? Now that java is porting value classes to mainline and we might have them soon, and planned operator overloading through type class, I believe java approach is making careful design choices that are semantically sound, rather than adding features that create edge cases such as boxing invariants in unions like C#.

comment 6mo ago · link · parent

Value types will be optionally null. What java will introduce to the tooling is narrowing of nullness types. Hence Foo! <: Foo? <: Foo. This will assist in enabling safe domains or scope in code that are null-restricted with ease. Hence we can model around such a type system rule.

comment 6mo ago · link · parent

Great stuff!!!

comment 6mo ago · link · parent

Yup. They started transferring to the main line, but will require many tests to know if they have any issues. https://github.com/openjdk/jdk/pull/31120
12