Earlier quoted context omitted.
Part of the reason Java hasn't reified generics is because C# did and it was a real big headache that also limited non-C# languages on the C# runtime (CLI?). Everything had to be recompiled to work with newer C# runtimes. While it's pretty easy to run a bunch of language on the JVM (Javascript, python, ruby, clojure) doing the same for C# is somewhat a nightmare, particularly for non-type aware languages. For example…
IronPython did just fine with reified generics.
Project Valhalla, Explained: How a Decade of Work Arrives in JDK 28
371–380 of 464 posts
Re: Project Valhalla, Explained: How a Decade of Work Arrives in JDK 28
#372After reading a lot of comments in here, there is one thing that always repeats itself in Java/JVM-related comment sections on HN. There are a surprising number of people who have an idea of what the JVM or Java used to be and have very little idea of what it is today. It is a very fit predator in 2026. Does it have its warts? Yes, but the substrate is extremely good.
Many of us work on Java monoliths that started in the 2000s when it was in vogue and we still have to keep them chugging along on Java 8. Personally I'm familiar with all the new features that have come out in the last few years, but for my actual work, java is literally stuck in the past.
Good news is, Oracle extended extended extended support for Java 8 will not last forever, and eventually - if you work in a regulated industry - the company WILL have to pull the trigger.
On the other hand, "where there is muck, there is brass", so a little bit of legacy can be beneficial for some.
Re: Project Valhalla, Explained: How a Decade of Work Arrives in JDK 28
#373They want basically to solve the main Java design flaw with (almost) everything is a reference paradigm. C++ and Rust have had value-types from day one.
> 64 bits, including the null flag
So, this basically makes every value-object optional, adds extra overhead and makes code less safe to null pointer dereference errors.
> but a class with, say, two int fields or one double may not fit in an atomic write and end up as an ordinary object on the heap anyway
So, the whole optimization is applied only for very small structs with no more than two scalars (or so). Did it worth to spend 10+ years of development to achieve this?
Re: Project Valhalla, Explained: How a Decade of Work Arrives in JDK 28
#374Earlier quoted context omitted.
The type erasure version of this would look a lot like Hack [1]. So generic arguments would simply have a ? if they allow nulls eg List . The list itself couldn't be null unless it was ?List . Now, one can argue that this is just smoke and mirrors with type erasure and it is but you can already put a Date into a List if you're so inclined because the JVM doesn't know the difference, hence type erasure. So this is no…
> Now, one can argue that this is just smoke and mirrors with type erasure and it is but you can already put a Date into a List if you're so inclined because the JVM doesn't know the difference, hence type erasure. And that's a massive problem that they're planing to solve with specialized generics. > If I read the correctly, it means that if you have a Point value class then on the JVM level you'll be able to stuff…
Re: Project Valhalla, Explained: How a Decade of Work Arrives in JDK 28
#375Java = Oracle = Ellisons way of doing business Unless your company forces you to use Java for new projects, consider a change
name another statically typed, compiled, mature language with a bunch of packages for everything and maybe I will /srs
Re: Project Valhalla, Explained: How a Decade of Work Arrives in JDK 28
#3761. Can someone remind me why it was so important/intentional at the start of the language that every object has identity? 2. Why is it important that we not synchronize on these value objects?
Re: Project Valhalla, Explained: How a Decade of Work Arrives in JDK 28
#377Re: Project Valhalla, Explained: How a Decade of Work Arrives in JDK 28
#378The article has a section about that. For me, a struct in C/C# can be modified and is passed by copy while a value class can not be modified and is passed by value. I do not think you can do stack allocation in Java.
Re: Project Valhalla, Explained: How a Decade of Work Arrives in JDK 28
#379wow, basic stuff c++ had since the 80s. congrats. clap, clap, clap. now can someone please make this app that is running with -Xmx360m not use 700mb of resident memory ? asking for a friend.
Re: Project Valhalla, Explained: How a Decade of Work Arrives in JDK 28
#380Earlier quoted context omitted.
Mistyped, it's sealed interface. > So you can always have `Maybe x = null`, or even `Some x = null`. Yeah and? Practically every type system have escape hatches, like Haskell can also do side effects without the IO monad, does it make the latter useless?
The whole point of using Optional/Maybe is to prevent the possibility of accidemtally creating nulls. If you don't make mistakes, then nullability is not a problem. If you do make mistakes, then a class that only helps when you don't make mistakes is basically useless. This also has significant impact for serialization/de serialization - a classic place where you get unexpected nulls, that Java Optional/Maybe don't h…
Types are both for the compiler, as well as for the developer. Maybe types are implicit documentation telling the developer that it is meaningful in the application that this field can have a None state.
That's a huge code smell to ever set null to an Optional/Maybe and code reviews, linters, nullness analyzers all should/will flag such.
Like I have never ever had an NPE from an Optional being null. Sure, complete null safety would be better of course, but in this very instance it ain't buying you much.