top | item 45261946

Java 25 officially released

320 points| mkurz | 5 months ago |mail.openjdk.org

255 comments

order

lukev|5 months ago

More new programs should be written in Java/on the JVM.

Most of the reasons Java dropped out of popularity no longer apply, and at this point it is an incredibly stable and mature ecosystem.

I can come back to a Clojure program I wrote ten years ago and it runs great, meanwhile a TypeScript program I write 6 months ago requires a bunch of updating and cleanup.

Foomf|5 months ago

Oracle makes me too uneasy. Can I use Java without the worry of incurring Oracle's wrath? Maybe, if I make sure I use openjdk/jump through some hoops I'll be fine. Or, I could just use any other language and not have that worry looming over me. C# is right there if I want a java-like experience without the anxiety of Oracle breaking my kneecaps.

I don't know how to use java and not violate one of Oracle's EULAs. I could read about it and figure out how to do it safely, or I could just not use java. Java isn't essential (for greenfield projects). There's lots of good alternatives, so I'd rather do that.

cgh|5 months ago

Java is hugely popular and widely used on large backend systems. I guess a lot of people here don't work on such systems? I'm always surprised when I see comments like the parent, since in my career exposure to Java is near-ubiquitous.

fnord77|5 months ago

I think Java is the best language for most medium to large projects or anything that requires threading or complicated/optimized IO

Especially now that hardware architectures are getting fragmented again, I hope it becomes more relevant.

I think Springframework is dragging Java's reputation down. I know Spring boot is better but it's such a monstrosity.

I feel like sadly Python has won the war, though. Good enough for most things even though it is pretty rubbish.

I see people trying to use Rust now for prod AI systems.

palata|5 months ago

I'm secretly hoping that Kotlin and Compose will bring back Desktop apps on the JVM :-).

pgwhalen|5 months ago

Java's biggest risk towards continued adoption, by far, is the culture surrounding it - old Java programmers and old Java programs continue to be needlessly verbose, even if the language now has the tools (pretty much) to be as terse as other popular, modern languages.

It's an uphill battle, but it might just climb the hill because it's still such a behemoth.

wry_discontent|5 months ago

In the circles I see, Java isn't popular because it's verbose and boring to use.

These days I don't see those as significant issues, tbh.

I would prefer a Clojure program, but I'll take Java over Typescript at this point.

iLemming|5 months ago

> I can come back to a Clojure program I wrote ten years ago and it runs great

Is that thanks to JVM or due to the way how Clojure works? Because I can share the same anecdotes for my Clojurescript projects. I can grab any old nbb script and things just work off the bat - sometimes I have to update some npm dependency, but most of the time, things simply aren't horribly broken. Meanwhile, I just spent half a day jumping around for weird Python dependency and venv magic dance, just for the sake of running five interdependent scripts.

sunshowers|5 months ago

Java has the same problem most imperative languages do, which is the lack of clear separation between mutable and immutable state, rigorously enforced by tooling. Many large-scale Java programs try and work around this by using immutable collections, which certainly makes a difference but can only go so far.

Java has the additional issue of being object-oriented, which leads to spaghetti parent-child relationships under stress.

Decabytes|5 months ago

My biggest Issue with Java, is that it isn't streamlined. There are multiple implementations of the jdk that could be used, Many different build systems, etc. The C# ecosystem is smaller for sure, but it is much more streamlined

AzzieElbab|5 months ago

It is probably more related to people replacing multithreaded services with single-threaded workers.

AlienRobot|5 months ago

I've been trying Java recently with IntelliJ and it's been funny watching Java's evolution from the IDE's suggestions.

In Java a lot of code looks like this

    void foo(Bar bar);
where Bar is an interface, and in many cases it only has one single method, so it looks like a callback that must be wrapped inside a class. Fortunately, Java lets you create anonymous classes to use these methods.

    void foo(new Bar { @override boolean baz(Fish fish) { return false; } });
I assume because this paradigm is so common somewhere along the way Java introduced "lambdas" that look like this (I learned this from an IDE hint)

    foo((Fish fish) -> false);
But what if you have a class that has Bar.baz method signature but it's called something else like fries()? Turns out you can do this (another IntelliJ hint):

    foo(this::fries);
This feels like a complicated way to declare a callback, but it means that if you do implement a method with the same name, you can just pass the instance, otherwise you can use the syntax sugar, e.g.

   saveMenuItem.registerMenuClickListener(myMenuClickHandler);
   saveButton.registerClickListener(myMenuClickHandler::onMenuClick);
There is a lot in Java that just feels weird, though. From the top of my head:

1. No unsigned integers. "byte" is -127 to 128. I believe this means it's not straightforward to make a 32-bit RGBA structure since you options are either using a signed "red" or using a 16-bit integer to store the 8-bit values. by the way I tried to benchmark how slow Java was compared to C in a simple test (I had arr1[] with indexes of arr2[] which contained values and I created arr3[] by resolving them) and it seems to be only half the speed of C which is probably fast enough for some basic low-level 2D graphics.

2. String.split takes a regex argument and there is no standard way to split without a regex. This was really confusing to me, but fortunately it's very easy to write your own .split, so it's not that much of a big deal.

3. You can call a different constructor with this(), but it has to be the first statement in the constructor. This one is pretty crazy! It would make sense if you couldn't access member fields before calling the constructor, but having to be first statement means if you want to calculate the argument for one constructor based on an argument passed to another constructor you need to do it inside the parentheses.

So far there is only 2 things I wish Java had. First the ability to implement methods in interfaces so you could use them if you have an interface instead of using a static method. Second I wish @NotNull was the default. This is a problem that Kotlin fixes so I think if you like Typescript for tis type-safety learning Kotlin would be a good idea.

lisbbb|5 months ago

After working with it for over 20 years, I think it's time has come and gone and that it's not the most efficient way to build enterprise applications anymore. You're lucky that Clojure program still works on the newer JVM because many of the applications I worked on, which were very large, could not be migrated to newer versions of Java. In fact, that experience repeated several times for me. I barely ever worked on anything that used the latest versions of the JVM, every place I worked was always on things like "Java 8" and crap like that. It was infuriating, but the situations were not unique at all.

bootman|5 months ago

Java has been such an amazingly solid technological foundation... and for a long, long time! It may not be the most sexy language but it's been a stable one. We have applications created with Java 1.4 running happily on Java 21 LTS and expect to upgrade to this latest LTS (Java 25) soon. Java for the win!

ivanjermakov|5 months ago

I wonder where Java would be today without superb tooling and smart student programs from JetBrains.

ilt|5 months ago

Kind of tangential, I still remember Gmail app created in Java which used to run on my touch Symbian phone in 2009. It was cute as hell and got the work done.

dionian|5 months ago

The JVM and its ecosystem can be used from other languages too like Scala which has all the sexy stuff, also clojure et al

freedomben|5 months ago

Neat, I wrote some swing apps back in the day that I've thought about resurrecting, but didn't want to have to do much modifying since they are mostly toys, though useful to me. I'm gonna give it a try!

lisbbb|5 months ago

I disagree. That has not been my experience whatsoever. Every company I helped, and it's been dozens, had struggles moving to a new versions of the JVM. Every single time there were major issues that required a lot of re-work and re-testing. I bailed around Java 17 or 18, but it didn't matter because NOBODY I was working with was actually even using that version! On one particularly bad project in 2022, a client had a security imperative to update the JVM from 1.5 on a major internal system and my role was to determine efficacy. I quickly found out that several key libraries had ceased support long ago around Java 1.7 and there was no path forward for those. They were simply deprecated products. My team tried getting the source code and re-compiling those 3rd party jars, with the idea of taking ownership of that code, but it was spiraling in terms of scope. They would not listen to me that even getting them to 1.7 was going to be problematic. Worse, some drive-by manager would not believe my appraisal and brought another guy to prove me wrong. It turned into this big pissing contest, which I resented. The other resource wasn't anywhere near as experienced as me, just kind of arrogant and overly confident. I decided to fire that client, which sucked because they were the tippy top of the Fortune 10. Last I heard, they had not made any progress with that upgrade and were still using it on 1.5.

BlindEyeHalo|5 months ago

Crazy that it took this long to allow parameter validation and transformation before calling super in the constructor.

That was something that always bothered me because it felt so counterintuitive.

delusional|5 months ago

Especially because you were always able to bypass it by declaring a `static` function and calling that as part of the parameters to `super`:

public Foo(int x) { super(validate(x)); }

validate would run before super, even though super was technically the first statement in the constructor, and the compiler was happy.

PaulHoule|5 months ago

I've been programming in Java since before JDK 1.0 and that was one misfeature that bothered me then but that I've long since learned to work around.

extraduder_ire|5 months ago

Wasn't that possible since java 22?

miki123211|5 months ago

(not a Java developer, no dog in this fight)

I'm not sure I like the module import system very much. I think `import *`-like constructions make code a bit easier to write, but much harder to read, especially for developers new to the language / codebase.

C# and Nim love that style, and it makes them almost unreadable without a good IDE.

Personally, I much prefer Python's "short aliases" style, e.g. `import torch.nn.functional as F`

pie_flavor|5 months ago

I have never understood complaints about language constructs that don't make sense without an IDE. You have an IDE, it is where you are viewing the code. People that don't have an IDE are causing their own problems and should stop. People viewing the code on GitHub are not really analyzing it at the level that requires finely tracing through references usually and the terseness drastically outweighs the occasional annoyance when you are.

deepsun|5 months ago

In large codebases the main problem with imports is "where that thing comes from" -- you really want explicit imports. Especially if something broke in build and you're not sure you have correct versions of dependencies (what dependency that name came from).

In small codebases anything would work.

PS: why do you even look at imports? Any decent editor just hides it, you never need it, you navigate just by clicking/hotkeys on names directly from code.

bob1029|5 months ago

> C# and Nim love that style, and it makes them almost unreadable without a good IDE.

I think a lot of what turns people off to the C# developer experience is not using full-blown Visual Studio. VSCode is great but I would never open csproj or sln files using it unless I needed to manually edit their actual XML contents.

It's not broadly advertised that you can buy a perpetual & fully licensed copy for $500 [0]. No subscription or other cloudy scam stuff is required, although Microsoft's product pages will initially lead you to believe it is.

[0] https://www.microsoft.com/en-us/d/visual-studio-professional...

samus|5 months ago

AFAIK it's mostly intended to make writing single source file programs easier.

dionian|5 months ago

so module imports looks to be different from normal imports and actually helps reduce the number of imports the developer needs to write. FWIW Scala (which runs on java) does have import renaming and also type aliases which can do what you mentioned.

mrsilencedogood|5 months ago

Damn, still not structured concurrency full release. Really looking forward to that one.

Happy to see Scoped Values here though. That'll be big for writing what I'll call "rails-like" things in Java without it just being a big "static final" soup in a god-class, or having a god object passed around everywhere.

pjmlp|5 months ago

Much better this way with previews, than the mess C++ is having nowadays with standardising features without implementations.

jayd16|5 months ago

I hope structured concurrency ends up feeling better than async/await with less sugar. The examples do not instill confidence, but we shall see.

thewisenerd|5 months ago

recently pulled the trigger on a migration out of jdk8

we decided to bite the bullet and do 21 instead of 17; one of the reasons being 25 being just around the corner.

as far as i can tell, the biggest hurdle is 8 to 11 (with the new modules system); but it's smooth sailing from there. the proof-of-concept was done with jdk17, but it worked as-is with jdk21 (except guice which needed a major version bump).

(of course being with a jvm language instead of java itself also probably helped)

MBCook|5 months ago

For us 8 to 17 was tough due to a lot of things you weren’t supposed to be using going away (sun packages). But TONS of libraries did it anyway. And the move from javax to jakarta for a lot of things in there was also tough.

If you could get through that, you’re golden. From what I’ve seen going to 21 or 25 look easy. They’re just adding features, the big upheavals of doing the long needed cleanup are over.

I expect keeping up to date to be far easier from now on.

pjmlp|5 months ago

Yeah, Java 9 was the Python 3 moment of the ecosystem, however it has been sorted out for ages.

foobarchu|5 months ago

For what it's worth, I had absolutely no hurdles migrating from 17 to 21 recently. Everything worked fine, the only minor issues were in upgrading Gradle at the same time (which was only tangential)

lisbbb|5 months ago

Best of luck to you.

palata|5 months ago

My feeling (which is worth what it is worth) is that Java as an old language has been improving over the last 10 years, whereas C++ has gotten worse.

al_be_back|5 months ago

The verbosity of Java may certainly annoy/put off new devs a lot, but with advanced tooling and ai, that's not a biggie i think. Personally, i think a live-reloading feature would make java very popular again, and rapidly so. In my internship (mid-00s), a senior consultant said to me "remember, we don't sell Java, we sell Sun". I thought that was backward, preferring "we sell English, and England offers an implementation, or you could chose the US, or a Canadian alternative perhaps? etc". Little did i know.

Java's from the era [1] of virtualization : machines, languages, web (with applets, flash etc) where you focus on writing code once, and delegate the running to a VM, reaching an ever growing list of platforms/devices the VM knew.

But then came Steve book of Jobs and vajazzled so-called phones and desktops, far better than Bill electronic Gates. Why write an App in java and have that run [2] on Phones, Web, Desktop and Server when you can create N-code bases, one for each platform and device?? Oh and why would you want games in Flash [3] when you could be saving your battery to watch a cat tumble over a dog in 8K definition???

Seriously though, I think, the vm era is going to come back in the next few years, and expand into new areas, such as UI vm to deal with os/platform specifics. A healthy-level of tech decoupling is a good strategy, for everyone, but not full isolation. The vm model is much better for consumers and devs - far less lock-in, more future-proof [4], more freedom to innovate and try new markets. Usually, the vast majority of consumers and most devs have ordinary / run-of-the-mill issues. Most popular apps/sites are about shopping, basic entertainment, library-functions (search, referencing, reading), and chatting.

[1] 80s/90s [2] with slight platform variations [3] Flash or some alternatives. Jobs banned Flash for security+energy consumption reasons. [4] abstract/wrap intricacies of lower layers

fnord77|5 months ago

It's a damn shame that project Valhalla still isn't finished. This would fix so much and open up java for better matrix math support

cryptos|5 months ago

The first time I heard about Valhalla was 2014 (if I remember correctly), so more than a decade ago! However, I'm very happy how Java is engineered. It is really the exception that a technology is so carefully developed. Java is the technology you want for long-term stability.

samus|5 months ago

Project Valhalla is too big to land in just one release. Even if all changes to surface language and the JVM land, it's just the beginning for adding new optimizations.

joe_mwangi|5 months ago

It was submitted recently 2 weeks ago hence we might see something in future releases too.

Yhippa|5 months ago

I've been away from the Java world for the past 4 years, and I really miss it. I hope I can get back to it soon.

This is cool: https://openjdk.org/jeps/512 (JEP 512: Compact Source Files and Instance Main Methods). It will allow beginners to progressively ease into the language and remove arbitrary gatekeeping from the language itself.

I also went down the rabbit hole on the Shenandoah GC JEP and learned that it was actually named after the Shenandoah Valley. Super cool.

suyash|5 months ago

Nice to see "Vector API (Tenth Incubator)" - it should open possibility of doing low level vector maths much needed by machine learning toolkit in Java.

samus|5 months ago

It's not that new though. It will probably only be frozen once value types arrive.

112233|5 months ago

What is the current situation of using Java (from legal standpoint)? In open source and in commercial setting? Oracle has a lot of fantastic technology locked up in Java (things like Truffle), how reasonable it is for new projects?

jeroenhd|5 months ago

OpenJDK is pretty much open and straight from Oracle.

If you don't like Oracle (and I wouldn't blame you), there are alternatives from parties ranging from the Eclipse Foundation to Microsoft and Amazon that will do the same thing.

As for new projects, Java is here to stay. It's longevity is part of why companies are still using Java 8/11; once you write it, it'll run pretty much forever.

The language lags behind in terms of features compared to pretty much any competitor, but it's functional enough to get anything important done.

I'd personally go Kotlin if you were to rely on the JVM (almost entirely because Java still lacks nullable types which means nullpointerexceptions are _everywhere_) or C# if you don't like the Kotlin syntax, but Java is Good Enough.

whartung|5 months ago

The only real nut right now is, if you're using the Oracle distributions, only the latest LTS is, essentially, free to do anything with.

Older releases are under their OTN license, which is only for personal and development, but not production.

Again, this only matters if you want an Oracle sticker on your runtime, OpenJDK and the other projects are full boat "do whateva" JDKs.

exabrial|5 months ago

There is literally 0 worry. OpenJDK is fully open source.

nirvdrum|5 months ago

Truffle is not part of OpenJDK. It's a separate project and licensed under the Universal Permissive License: https://github.com/oracle/graal/tree/master/truffle.

The UPL is an OSI-approved open source license. It shouldn't be a problem to use in any setting, but you should check with your legal team to see what licenses are approved.

piva00|5 months ago

Use OpenJDK (or similar) and you are free from any Oracle shenanigans.

deepsun|5 months ago

It's only a consideration if you are going to write your own Java implementation and distribute it.

joegreen|5 months ago

I was really surprised to find out that the support for the STR string templates that was added as a preview feature in Java 21 was completely removed in Java 23 and there is no replacement at all.

lolive|5 months ago

Whoever criticises Java in the modern world will have to answer to this: if your IDE of choice does not provide a safe « Extract method » capability, then your langage largely sucks.

aw1621107|5 months ago

> if your IDE of choice does not provide a safe « Extract method » capability, then your langage largely sucks.

Why is that a language problem as opposed to an IDE problem?

alwahi|5 months ago

i think its time for some of the enterprise customers to maybe consider upgrading to java9?

steve_taylor|5 months ago

Does it have reified generics yet?

alwahi|5 months ago

i think some of the enterprise users should maybe consider upgrading to java9?

HackerThemAll|5 months ago

No, thank you. I've never touched Oracle products in my entire career, and that's my no. 1 directive forever.

Longlius|5 months ago

As opposed to Google, Meta, and Microsoft?