Java 24
jdk.java.net
jdk.java.net
I really want structured concurrency out of preview!! I think it helps close one of the last gaps golang has over Java in the ease-of-concurrent-programming side of things. Go makes channels and waitgroups pretty easy. I think structured concurrency is a great side-step of those primitives by actually making the higher-level tasks you use those tools to accomplish easier to write and reason about. Continuing a trend I see where go tends to have somewhat better primitives, but then obstinately does nothing with them to actually make the higher-level tasks easier to accomplish.
No pinning virtual threads is huge. Finally you can virtual thread with near-wild abandon, as God intended.
Love seeing Streams still getting love. I do a lot of fizzbuzz-esque interviews (the "can you code your way out of a paper bag" type screens) for my company and I think it says a lot that, in general, people who pick Java and use streams pass but people who don't use streams often get tripped up in their loop logic and fail (or, even if they don't fail per se, don't pass). It says a lot about ergonomics and intuitiveness, and also the power of the abstraction to tersely and compactly solve real problems, when a language is a big ally in interviews. And the cool thing about Java streams is that they're as powerful as Ruby's functional-style operation chaining (arr.map{}.reduce(:+) etc) but they're actually performant. I feel it also bears mentioning that people who use Ruby in these interviews, few as they are, almost always pass and do so while writing very few LOC :)
https://vorpus.org/blog/notes-on-structured-concurrency-or-g...
I think Kotlin still leads here, and even the Java changes don’t have the same nice ergonomics you get with Kotlin’s DSL. Would love to see more tenseness from Kotlin leak into Java.
Kotlin has the issue of being a guest language, and wanting to play in many playgrounds, eventually it will diverge as it always happens.
As it is already happening, like now how will Kotlin async deal with virtual threads expectations, including writing portable code that doesn't suffer from runtime semantics, depending on the target platform.
I stopped at "go statements are a form of goto statement."
This is simply not correct. They have some diagrams and squinted and said "hey, that looks the same as a goto statement", but unfortunatley they have their diagrams wrong. "go func" will run at scheduler's pleasure, not immediately after the statement "go func..". A goto statement is a deterministic flow control directive. It will goto where you tell it.
[0] https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.p...
If SVTwP is not better than NIO; Java ends with JDK 23.
> Warnings issued in JDK 17–23 generated minimal discussion in the Java ecosystem
Because no feature added after 1.8 made sense, so nobody upgraded. They are taking decisions off the wrong data.
> they are encouraged to transition to alternative sandboxing and API interception mechanisms
Feel free to link to anything useful!
I don't think I buy your assertion that nobody has upgraded. I know of a 3000-4000-strong eng org at a certain company that has upgraded all the way from 8 to 17 as of when i left 3 years ago. They primarily wanted the GC improvements because they translated into huge immediate efficiency gains on their workloads (huge Spark/Hadoop spend savings, and moderate savings for the non-big-data jvm workloads).
I do share your lament of applets though. It would've been a way better runtime for portable/install-less/JIT-install things than the current nightmare of html/css/js/etc. But they just didn't have the browser integration - it would've needed to be more than just "look we put a drawing surface into the web browser" - and they didn't have the "window into the world" either (that's browsers). Unfortunately, it's the front door program and platform that owns the users, and that's web browsers.
> I don't think I buy your assertion that nobody has upgraded.
Nobody that uses Security Manager has upgraded I meant.
Nothing sticks out, except container companies are probably very happy?
I wonder if the guys working on this did a search before starting: https://github.com/search?type=code&q=AccessController.doPri... (187k files)
This work is destructive for no reason.
But I am curious how classloaders will work now!?
I also dislike the Win32 removal since JDK 22, but I understand that Windows 32-bit assembly is un-maintainable. There is a reason ARM keeps 32-bit.
The Security Manager was not so hard to maintain it merited a removal without replacement.
It sounds like the OpenJDK folk disagree with you, though. From the JEP:
>The Security Manager has not been the primary means of securing client-side Java code for many years, it has rarely been used to secure server-side code, and it is costly to maintain
>...Improve the maintainability of hundreds of JDK classes that currently delegate resource-access decisions to the Security Manager.
>The OpenJDK Core Libraries Group devotes significant time and energy to reviewing every change to any of these methods. Every new API must be designed, and its implementation carefully audited, with the least-privilege model in mind. However, only a tiny number of applications actually enable the Security Manager.
This seems like a big win in terms of maintainability of the core libraries.
But its biggest weakness is that it has to restrict a lot of overly powerful APIs. That's like spooning water with a sieve. It would have been better to let the host application restrict which APIs are visible in the first place, like it is done with browser APIs.
The projects that didn't upgrade so far are either dusty business-crirical applications that nobody cares to touch or that utterly deprioritize upgrades unless circumstances force them to. Most of the new features make a lot of sense, but nobody is going to gamble their job on forcing an upgrade just to being able to use them.
To suppress things like `System.exit(0)`, agents can be used. Proper sandboxing solutions would be VMs and containerization technologies. Achieving perfect sandboxing within a process is hopeless anyway.
I'm guessing they thought it couldn't hurt to do another round of testing. Since OpenJDK 25 will be an LTS release, I suspect it will go out of preview in the next release.
I see that formerly it pinned virtual threads "when it executes code inside a synchronized block or method", and "frequent pinning for long durations can harm the scalability of an application by capturing carriers". You were supposed to "avoid frequent and long-lived pinning by revising synchronized blocks or methods that run frequently and guard potentially long I/O operations to use java.util.concurrent.locks.ReentrantLock instead."
How big a problem was this in practice? On the one hand, I think "harm the scalability" is putting it mildly—if you have a whole bunch of virtual threads doing IO, only running num_cores of them at once is devastating. On the other hand, holding a lock while doing IO smells wrong. Is this really common?
It can deadlock and cause crashes if you do use a library impacted. It's sometimes hard to tell and you'd have to dig into the source. Sometimes the library maintainer wouldn't update the code to a different method for <reasons>.
> Is this really common?
Yes, maybe not in obvious ways e.g. many developers use Spring, which is backed by a large organization and you'd assume to have things covered but under the hood Spring itself uses many libraries and some often open source without much support (can be a personal project by a single developer).
Those usually have company / community backing that gets it fixed. The irony is you patch the ORM and you patch the JDBC driver only to realize the database pooling library in-between is the 1 that's broken and the author refuses to fix it.
Library authors really don't want this kind of code churn for an issue that is not their fault, not their responsibility to solve, and that will get a bugfix before long that maybe even qualifies for a backport to LTS 21.
In C# the API is a bit overturned for sharing a GUI thread but it does the job. Structured Concurrency makes the scopes more obvious but I'm worried about the ergonomics. What is the core use case for the design? Is it just to make collecting a set of concurrent tasks bullet proof? Are we going to see scopes abused and passed around to handle the non-happy path of "a function always ends before it's caller."
It doesn't seem to service GUI programming all that well. I guess there's still Kotlin's approach but hopefully something happens on the Java side.
At a surface level, yeah basically. And ask anyone who's used python's multiprocessing how hard that is to actually get completely right.
I don't think structured concurrency is going to be some panacea of multiprocessing at all. It's to address code you'd see in golang that's like, make a waitgroup, fire off N goroutines, wait for success and gather errors. That code is not incredibly fun in Java right now.
w.r.t. async/await, imo the beauty of virtual threads is that you've no longer got function coloring, and the "await"s are free, implicit, and performant. and of course you're never precluded from using higher level application locks that have always been there, including synchronized now.
Also, specifically w.r.t. gui programming, I think Java is unfortunately kind of stuck. JavaFX has been put into the back of the closet, Swing is completely ossified (though tbh I still like it), and what energy is there behind any non-electron/web GUI development anymore anyway? In a world where vscode, one of the most popular new "IDEs"/IDE platforms, is written in a frickin web browser, and mobile apps dominate a huge % of what constitutes "native" GUI development, I don't really blame Java for not prioritizing it beyond keeping Swing working on e.g. hiDPI displays and so on.
This is not a unique Ruby feature though. Iterators are very common nowadays. Java streams have okay performance, much like .NET's LINQ you likely won't be able to use them in a really performance-sensitive code (although LINQ is improving quite a bit with each new release, overall it performs moderately to significantly faster than Java Streams, but usually slower than Rust iterators).
Just like I expect WebAssembly security conversation to change when folks start plugging components left and right, beyond straight compute logic.
I think you were proven right at least a decade ago. As you said, this is just the final whimper.
Have ALL previous pinning scenarios been resolved, including native calls?
Raspberry 2 and Vision Five 2 are very future proof peices of hardware that Oracle and OpenJDK ignores!
At this point there is no/little functional difference between distributions. The main reasons for using Oracle's distribution are usually non-technical and have to do with compliance, existing license & support agreements with Oracle.
Unless you are a bank (or similar organization) that has deals with Oracle on this or your CIO/CTO/legal tells you to use Oracle, you should avoid Oracle. There is no technical advantage and you potentially expose yourself to complicated licensing and commercial requirements and related auditing requirements.
Oracle also distributes the JDK with that same licence here: https://jdk.java.net, so there are two Oracle distributions with two different licences, both free but one open-source.
Understandable. Depending on your use-case, sure go ahead and stay there.
However keep in mind that you're missing out on a lot of stuff. Java 8 is like literally from 11 years ago.
I will compare my NIO multiplayer system to SVTwP (Sync. Virt. Threads without Pinning) and report back!
Theoretically it means, Java has now bettered Node.js "async / await" approach and that too without the two colored function approach. One process can now spawn thousands of threads to service IO and none of those threads are blocking / waiting (and with this release there is no gotcha / pitfall remaining).
Not mention all the Netty / reactive libraries have no use now (not that I am complaining).
Netty uses an eventloop/async paradigm. The benefit of that style is you do not need any locking (within the same eventloop). How does virtual threads make that of no use?
Is it good practice or not to use locking semantics if you use virtual threads?
understandable. Normal java threads have underlying OS threads, which have their own stack and memory overhead. virtual threads are much lighter in this sense.
Thus Kotlin will always be a guest language and not the target of all companies designing JVM implementations.
That is left for Google with their .NET flavour, ART + Kotlin, where Android Java plays the same role as J# did for .NET, after Microsoft had let go of J++.
If you a writing libraries for the JVM, Java is preferred to Kotlin because it does not drag along a standard library dependency.
To be fair there is Kotlin Multiplatform where this is not the case. https://kotlinlang.org/docs/multiplatform.html
It is no different than writing C code across UNIX, Windows, mainframe, microcomputers and embedded, consoles, and somehow work across all of them.
And this only happened, most likely because the Android team realised Kotlin was losing access to modern Java libraries, with ART being stuck in Java 8, so there was an update cycle for Java 11, followed by one for Java 17.
So far there are no public plans to update ART for something newer in Android 16, from the previews made available thus far, they actually also started rewriting OS components into Kotlin, it is no longer only Jetpack libraries.
In general Java is getting better but more weighed down by legacy and existing design decisions than Kotlin, so a lot of improvements from Kotlin are not possible to be made in Java.
Java is running ahead of Kotlin in a few things, mainly virtual threads which don't require black-red functions like coroutines.
I haven’t really given kotlin a fair try, but I find it ugly the couple times I’ve tried to work with it.
What I’m really curious about: do IntelliJ’s refactorings work as well for kotlin as Java? I find the refactoring tools make up for Java’s shortcomings as a language.
This seems awfully close to "avoid Spring" to me, heh.
Though, I've grown rather fond of Spring Boot over time, but I've gathered that's not exactly the popular consensus.
Exactly :)
Kotlin used to be a marked improvement over Java.
A series of large language changes, starting with JDK 16, have leveled the playing field somewhat.
Nowadays Java has Record types (data classes), sealed interfaces, pattern matching, etc.
Java's pattern matching actually got the ability to use guard clauses in match expressions BEFORE Kotlin implemented it:
https://kotlinlang.org/docs/whatsnew21.html#guard-conditions...
If Java had the ability to write free-floating functions outside of classes, and to declare function types succinctly like:
(String, Number) -> Number
It'd probably be on-par with Kotlin for me.Kotlin has a lot of other smaller features that help with conciseness. Like single line methods, but it’s still missing critical features like checked errors.
Pick your poison.
It is actually a central part of Valhalla now [1].
Pieces of it are landing. Flexible constructor bodies will be finalized. Generics over primitive types might become part of Java 25.
The pain with allocation is temporary. It is one of the candidates to become value types.
Lots of goodies.
https://docs.oracle.com/en/java/javase/22/core/stream-gather...
Ahead Of Time (AOT) linking is nice as well, should cut down cold start time.
the development team could either lengthen or shorten a couple of development cycles to stay in sync with the years.
- Stabilized FFI library
- Unnamed variables and patterns
- Always improvements to GCs and the runtime. Compact Object Headers v2 might be worthwhile on non-critical systems even though it's still experimental.
This will get you up to Java 21,
https://advancedweb.hu/a-categorized-list-of-all-java-and-jv...
For the remaining ones,
https://www.infoworld.com/article/2335077/jdk-22-the-new-fea...
https://www.infoworld.com/article/2336682/jdk-23-the-new-fea...
https://www.infoworld.com/article/3491404/jdk-24-the-new-fea...