Live data from Hacker News

JEP 401: Value Objects (Preview) merged to OpenJDK master

github.com

111–120 of 185 posts

Re: JEP 401: Value Objects (Preview) merged to OpenJDK master

#111

Earlier quoted context omitted.

What I love the most is the sheer amount of thought and philosophy put into Valhalla. It transcends the binary understanding of object vs value and actually defines 4 distinct buckets: 1: Classical Object 2: Object without identity 3: Atomic Value 4: Classical Value (Tearable) Each bucket has clearly defined performance characteristics and semantic constraints. So depending on the nature of your data, you can always…

this comment reads like a parent who can’t help but love their child unconditionally and uncritically. That’s a lot of complexity a lot of other languages don’t even need. It’s great Java designers have managed to shoe horn something in, but it’s all because of misdesigns 30ish years ago mispredicting of computer architecture.

I think you've misunderstood, because not only would this have been the right design if it had been in Java since day one as it's in line with the philosophy of the platform, it's also simpler than in other languages.

The idea is that instead of controlling memory layout and referencing directly, you communicate your intent: do you care about this value's identity or not? Do you need atomicity or not? Do you need nullability or not? Once the intent is clear, the compiler is free to choose the most appropriate and efficient layout for the particular value at the particular use site. In other words, you say what semantics you're interested in rather than how to implement them at the lowest level.

This opens up optimisation opportunities that are lost when the programmer directly controls the representation rather than the intent. E.g. in other languages you may say whether you want to pass some value by reference or by value. Here the compiler is free to say, well, if identity and nullability are not needed here, I can either pass by value or by reference, and I'll do whichever is more efficient.

And by the way, your point about early misdesign (whether it applies here or not) also inverts the desired state. Every language makes decisions that will be suboptimal in the environment some time later, and Java certainly has its share (its mutability and nullability default; how it treats serialisation). Rust, for example, was first designed twenty years ago, and some of its fundamental decisions reflect the state of the world at that time (it went all-in on some C++ premises that seemed fine 20 years ago). But since important codebases often outlast the outdatendness of early language decisions (your OS and your browser are running some >30yo code and/or affected by >30yo design decisions), one of the things most important in a language isn't the decisions it makes early on - some will prove "wrong" while your codebase is still alive and kicking - but how well it adapts and evolves. So when you pick a language for an important project today, the language's current state will end up mattering less than how the language evolves in the future. The question asked isn't "will I like this decision today?" but "will I regret this decision ten years from now?" Java is one of the languages with the lowest "regret factor", possibly lowest of them all.

Re: JEP 401: Value Objects (Preview) merged to OpenJDK master

#112
post #16

It's pretty interesting that while both languages still receive new features, Java seems to stay ahead of JavaScript: - Java has long had a modern replacement for Date, while JavaScript's recently standardized Temporal API still isn't supported in Safari. - Java has switch expressions, while JavaScript, despite its Scheme influence, does not. - And now Java is getting value objects, while JavaScript's equivalent tupl…

> JavaScript was not developed as a fork of Java, but much of its basic syntax still resembles Java, so I think it's fair to compare them. It's absolutely irrelevant to compare these two languages. Calling the former "Javascript" was just a marketing trick.

> It's absolutely irrelevant to compare these two languages. Calling the former "Javascript" was just a marketing trick.

Playing devil's advocate: back when you still could use Java in the browser, you could use Javascript to script your Java applets.

Re: JEP 401: Value Objects (Preview) merged to OpenJDK master

#113
post #97

Earlier quoted context omitted.

Show me where IStatusChangeEntityCreationManagerFactory is in the language. Or the standard libraries. Or anything like it

https://docs.spring.io/spring-framework/docs/current/javadoc...

lol it’s so long it overflows the window and breaks the css on my phone.

Re: JEP 401: Value Objects (Preview) merged to OpenJDK master

#114
post #32
post #27

Earlier quoted context omitted.

Is there a writeup on why they choose to destroy the history?

You can recover the history using their tooling build on top of their bugtracker and GitHub. Specifically they capture the discussions and all small changes over time in their skara tools and are prepared to leave GitHub if needed. They had multi de adres experience and had multiple prior code repos. Still do if i understand as the Oracle team has the sun and bea code repositories pre openjdk preserved.

Before openjdk did move to github, they made sure they had a solution for those problems:

* Contributors without github accounts * Moving away from github (when needed) * No vendor lock-in for github stuff.

I personally think, this is a good idea - a lot of work, but may be worth it in the long run.

Re: JEP 401: Value Objects (Preview) merged to OpenJDK master

#115
post #15

I feel lonely in that: I mostly love Java as a language. The lack of value types is the biggest impediment to certain types of performance. I am really looking forward to this evolution of the language.

I've said this before but I'll say it again: The worst part of Java is Java programmers. For most of my career, I thought I hated Java, primarily because every piece of Java code I had ever worked with was overly verbose across a million different files to do things that would take like ten lines of code in any other language. Then I actually started looking at all the features for Java 8, 11, 17, and 21, and realize…

I'd say a lot of verbosity comes from generalization -- when you want the code to be reusable and moddable (pluginable). No wonder two widely moddable games (Minecraft and Kerbal Space Program) are written in Java and C# respectively, makes it very easy to create mods. Once I tried to make a Go project at least build-time moddable and found myself creating a lot of java-esque Factories and Builders.

Whether that generalization is premature -- I don't know, just my observation on why.

Re: JEP 401: Value Objects (Preview) merged to OpenJDK master

#116
post #108

Earlier quoted context omitted.

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

The problem is not that the array is mutable, but that the size of the array may differ for different strings. (In fact, it usually* does differ if the string length is different). This makes it impossible to flatten - as the VM needs to know the total size when creating the memory layout for a class... * (with a small exception: if the strings use different coders, one can be twice as long and the backing arrays wou…

Indeed. At this point you’d need to bring the size of the string into the type system (C++ Templates we meet again!) but then you look at a solution worse than the problem…

Re: JEP 401: Value Objects (Preview) merged to OpenJDK master

#117
post #15

I feel lonely in that: I mostly love Java as a language. The lack of value types is the biggest impediment to certain types of performance. I am really looking forward to this evolution of the language.

I agree fully. It may not be perfect but it works really well, has a huge community, and I like the language.

I mostly ignore online discussions about Java. So much of it just feels like memes. Complaining about things that haven’t been valid in a very long time. Sometimes almost 2 decades.

It feels a bit like people bashing Nickelback. It was the “cool” thing to do. Maybe they’ve never used Java. Or only for one college course.

People can dislike Java. I’m sure some do. It’s fine. But it seems like the anti opinion is really over represented/amplified.

Re: JEP 401: Value Objects (Preview) merged to OpenJDK master

#118

Earlier quoted context omitted.

I've said this before but I'll say it again: The worst part of Java is Java programmers. For most of my career, I thought I hated Java, primarily because every piece of Java code I had ever worked with was overly verbose across a million different files to do things that would take like ten lines of code in any other language. Then I actually started looking at all the features for Java 8, 11, 17, and 21, and realize…

I'd say a lot of verbosity comes from generalization -- when you want the code to be reusable and moddable (pluginable). No wonder two widely moddable games (Minecraft and Kerbal Space Program) are written in Java and C# respectively, makes it very easy to create mods. Once I tried to make a Go project at least build-time moddable and found myself creating a lot of java-esque Factories and Builders. Whether that gene…

I don't agree with that though.

I've written plugin systems for stuff I've worked on, and it didn't require nearly the same level of verbosity. Granted, I usually have done this with sockets instead of directly using JVM and reflection. To each their own, but I like using sockets (usually ZeroMQ) for this stuff because then it's completely language independent.

Even if I granted that you needed to use all this factory and builder glue stuff, I don't agree with the typical Java developer's strategy of breaking things up across a million files, which Java at least greatly encourages.

Re: JEP 401: Value Objects (Preview) merged to OpenJDK master

#120
post #15

I feel lonely in that: I mostly love Java as a language. The lack of value types is the biggest impediment to certain types of performance. I am really looking forward to this evolution of the language.

java the language is amazing the problem with it is entirely cultural. why is `IStatusChangeEntityCreationManagerFactory` everywhere? and why are the frameworks so huge and all encompassing? i think batteries included rails-style frameworks are great, but when i wrote Java, it didn't feel like rails at all none of these are language problems

I have never run into code like that in any of my jobs.
Post reply on HN