#Java
enthusiast with a passion for learning and sharing, DevRel at Oracle but views are my own // ๐
@nipafx
@mastodon
.social // โ๏ธ
@nipafx
.bsky.social
I'll also collect all threads in this thread of threads. ๐งตยฒ
From modules to serialization, from pattern matching to value types, form generics to networking, whether it's new versions or upcoming JEPs - here they all are (and many more to come).
Enjoy, like, retweet. โค๏ธ
In two weeks,
#Java19
will be released with some of Java's most anticipated features: virtual threads and structured concurrency! ๐คฉ
To make the best use of virtual threads, servers/frameworks need to support them - here's a list of those that do (reply with those I missed). ๐งต
Yesterday evening, we spent about two hours digging through the German
#Corona
app and I'm thoroughly impressed. This is a modern project, developed out there as free software (APL 2.0) on GitHub, and it has stellar documentation.
Let's have a look! 1/๐งต
#Java21
is gonna be big! One recent addition:
// in
void main() {
System.out.println("Ha!");
}
# run with
java
That's all it takes. ๐ฎ More on that and the rest of the on-ramp in today's Newscast:
Just finished adding
#Java13
changes to my slide deck covering everything new after 8:
(2D slides; use PgUp/Down)
It has 250 slides! I double dare you, say 'Java is slow' one more goddamn time!
#Java21
will be bonkers!
So.
Many.
Features!
Finalized, improved, brand-new - a ton of each.
I'll tweet them out one by one throughout the day with links to JEPs and videos. ๐งต If you can't wait that long, watch today's Inside Java Newscast:
Java devs no longer need the visitor pattern!
With sealed classes (final in
#Java17
) and pattern switches (preview in 17),
#JavaNext
offers a better and shorter solution to the problems the pattern addresses.
#Java19
is gonna be an amazing release ๐คฉ - the most break-through in a few years and probably for a few years to come. Here's why, from least to most groundbreaking feature (IMHO). ๐งต
(If you want to follow up on something, the video description has tons of links.)
In a few days,
#Java
turns 28 and to celebrate we got something special for you:
28 HOURS OF JAVA - an early birthday party with guests, games, presentations, and code.
Join
@ammbra1508
,
@Sharat_Chander
, and me from Saturday 04:00 to Sunday 08:00 (UTC).
You know
#Java16
's records. You maybe also know Lombok's @โData and
#Kotlin
's data classes. They're all just boilerplate-avoiders, right?
Wrong. Records are all about something else and that makes them better* than the other two.
You're never gonna believe this, but my book, The Java Module System
@ManningBooks
, is finally released! ๐ป Final PDF can be downloaded now, epub and Kindle will follow shortly, dead-tree version on July 5th.
(With code "fccparlog" you get 37% off.)
Here are 11 improvements you get when updating to
#Java16
later today: from records and type patterns to `Stream`-additions and Unix domain sockets, from creating installers to more performance and observability. ๐งต๐๐พ
(Longer form with tons of links: )
Babylon is
#OpenJDK
's newest big project, aimed at easing execution of Java code on the GPU, which will unlock machine learning and artificial intelligence on the JVM. More about it's background, prototypes, and plans in the latest Inside Java Newscast:
Pattern matching in Java is taking its first steps out of the lab with switch expressions:
T result = switch (arg) {
case L1 -> e1;
case L2 -> e2;
default -> e3;
}
Personal guess/hope: we get that in
#Java11
. Would be awesome!
#ProjectLoom
's virtual threads will make high performance in concurrent systems attainable with much simpler code. But Loom aims for even more and wants to make the code clearer and more robust by introducing *structured concurrency*.
Here's what that's all about. ๐งต
Excited for the
#Java21
launch? So are we! ๐ฅณ
So much so that we'll be talking about it for 8 hours straight: technical explorations, expert interviews, and community voices at
@parisjug
and
@jugka
.
Be there on Tuesday, Sep 19th, 1300-2100 UTC!
Details:
What's it called when multiple threads execute at the same time? Parallelism? Concurrency? ๐ค Is there a difference? (Spoiler: Yes!)
Let me explain in a few tweets, ripping off
@pressron
's
#InsideJava
blog post "On Parallelism and Concurrency". ๐งต
According to
@OracleDevs
, there are 12 million
#Java
devs. According to
@snyksec
, 60% of them primarily use Maven. Did you know the build tool used by ~7 million people is maintained by 5-10 core developers?
Ask your lead to give you a day or two to tackle one of these issues.
#Java18
comes out later today - what can you expect from Java's newest release? Here's a ๐งต with one tweet per feature - short and sweet.
For more details and links, read this blog post:
For questions, join our
#JDK18
AMA later today. ๐๐พ
Hey
#Java
developers, โ๏ธ
#JDK18
is arriving of March 22nd. Join us in a Twitter space @ 20:00 UTC where we will cover whatโs coming in the newest version of Java as well as answer questions!
See you there!
#Java11
is out! ๐ฅณ๐ Download, install, experiment:
Want to migrate from 8 to 11? Here's everything you need to know about that:
(Licensing, LTS, preparations, version requirements, branching, migration challenges, everything!)
Ready for a new programming paradigm in Java?
#Java21
is the first release with all essential pattern matching features finalized. On the last stop on
#RoadTo21
, we're exploring that in depth and see how they come together for data-oriented programming:
Java turns 26 soon, so mark your calendars and get your โ, folks, it's time for another live stream marathon! Or rather, a relay race. On May 29th, I'll be joined by
@sebi2706
,
@BillyKorando
, and
@jitterted
for 26 hours of Java.
#26hJava
Check for more.
Alternative to the 9 lines:
var file = Path.of(fileName);
return Files.readAllLines(file);
Won't this mostly create "legacy" code because most code is "legacy" (i.e. not using current features and APIs)?
Couldn't be there on Tuesday for the
#Java21
live stream? Or maybe just not the entire 8 hours? ๐ณ
No worries, the video is up under the same URL () and I just added time stamps, so you can easily skip to the portion you find most interesting. Enjoy!
Since
#Java11
you can write single-source-file programs and throw them at the JVM without having to compile them first:
And the crazy thing, you can add a shebang line and write scripts this way! ๐คฏ
Virtual threads are amazing, but only half of Loom's play. The other half is making use of quasi infinite threads with a new concurrency programming model: Structured Concurrency.
JEP 428 proposes that - will it make it into
#JDK19
? ๐ค
I've been writing more Twitter threads since the beginning of 2021 and I really enjoy it. It's challenging but rewarding to cut a topic into a dozen little pieces that tell a story yet stand on their own. Judging by your reception, you like them, too.
So they'll keep coming! ๐
Who needs chocolate when they can have Java features in their advent calendar? (Yes, I'm late, but fashionably so. ๐)
From language features to API additions, from tooling to performance, here are 24 Java features you missed in 2022!
As ๐บ:
As ๐งต: ๐๐พ
I never lie to my 8yo daughter. Even when she asks about sickness and death, sex, or now war - I may simplify but never evade nor sugarcoat.
Today she asked me whether Putin may fire atomic missiles. I lied: I said "no".
๐ข The long awaited finalizations of pattern matching in switch () and of record patterns () are now proposed to target
#JDK21
. ๐๐พ
(Looks like this happened only a few hours ago, so you heard it here first, folks!)
Billy used all the best words already, so I'm left with:
Same here.
Ok, I have a few more. ๐ I'm super-thrilled to be on the very team that evolves Java and that I can now spend *all* my time sharing the amazing work they're doing.
Happy to announce that I am joining the Java Developer Relations team
@Oracle
and today is my first day! ๐คโ๏ธ
I have been a Java developer for over a decade and I'm super excited by the opportunity to help grow and shape the Java Community! Let's get started!
Project Loom aims to bring structured concurrency to Java, a concept that compares to "regular" concurrency like structured programming compares to GOTO-programming.
Dip your toes into this concept with the latest Inside Java Newscast:
This is really cool, a curated site listing recent developments in Java:
If done right, this can make it an order of magnitude easier to observe Java's evolution. Great initiative! Check it out, bookmark it, read it.
#MovedbyJava
A number of very interesting announcements at
#JavaOne
about:
*
#JavaFX
๐ซ
*
#GraalVM
๐
* high performance JDK 8 ๐
* generational ZGC ๐ถ๐ง
Let's have a look! ๐งต
(If you prefer video, watch the latest Inside Java Newscast: )
๐ฃ
#Java21
is no long-term support version!
Don't worry, there'll be plenty of JDK 21 builds that get free, timely updates and lots of companies that offer commercial support, but that doesn't make 21 "an LTS version". Let's talk semantics! ๐งต
As video:
Static `Predicate::not` will make it easier to invert Boolean lambdas in
#Java11
:
List<String> list = reader
.lines()
.filter(not(String::isEmpty))
.collect(toList());
Some people say Java evolves slowly.
I say, we got collections in 1998 and ๐ฅ 25 years later we (probably) get `List::getFirst` and `getLast`. ๐ But also a way for easy reverse iteration/streaming. Let's have a look! ๐งต
(If you prefer video: )
๐ข Curious to learn the tricks behind
#1BRC
for processing 1B rows really fast? Then join
@ElliotBarlas
,
@royvanrijn
,
@thomaswue
, and me on Thursday this week for a live stream with
@nipafx
, where we'll dive into all the secrets ;)
๐๏ธ Feb 1, 7pm UTC
๐บ
JEP 427 proposes the third preview of pattern matching in switch with two changes:
* guarded patterns (`&&`) are out; `when` clauses are in
* total patterns no longer match `null`
JEP:
More in the next Newscast - subscribe:
#Java22
will be forked and feature-frozen later today. It finalizes:
* unnamed vars/patterns
* FFM API
* multi-file programs
* G1 region pinning
And it previews a lot more:
* statements before this/super
* stream gatherers
* โฆ
More on all that:
[NEW VIDEO] In
#Java12
, old imperative `switch` becomes more powerful and elegant:
boolean b = switch (bool) {
case TRUE -> true;
case FALSE -> false;
case FILE_NOT_FOUND ->
throw new
RidiculousLogicException();
};
Details:
A little later today,
#JDK18
will fork from the main development line, thus feature-freezing Java's next release.
From pattern preview to foreign function incubator, from Unicode to a web server - here's what you can expect! ๐งต
What are Java's plans for 2024? Besides improving/finalizing current previews...
* Amber: withers๐ค๐พ, primitive patterns (JEP 455)
* Loom: reduce pinning/capturing
* Panama: FFM buffs, jextract
* Valhalla: JEP 401
More on that and other projects:
Remember earlier this week, when Java's stream API didn't have that intermediate operation you needed? It will soon get it.
Which operation am I talking about? All of them! Thanks to Gatherers, we can easily and seamlessly implement our own:
Over the last two days I experimented a bit with Project Loom and built...
* a folder size analyzer
* an echo server (thanks for the help,
@mmirwaldt
)
Each with and without virtual threads, which makes a huge difference (๐งต๐๐พ). Check it out:
@gunnarmorling
@java
Static method `Predicate::not`, which I really like because I prefer method references over lambdas:
.filter(string -> !string.isEmpty())
// with static import
.filter(not(String::isEmpty))
Happy
#Java20
release day, everybody! Get the freshest JDK right here:
Let's have a quick look at how the preview features progressed this release (after we looked over all the small and not-so-small additions to 20 last week ๐๐พ).
๐งต
The list of big features
#Java20
finalizes is rather short: . (That was it already. ๐ฅฑ) All 20 improves is security, performance, tools, regex, Unicode, and all previews.
Maybe worth a closer look after all?
("This thread should've been a blog post." )
โฑ๏ธ Just ten more days until the release of
@java
17, the next version with long-term support! To shorten the waiting time a bit, I'll do one tweet per day on a cool feature added since 11 (previous LTS), introducing just some of the changes making worth the upgrade. Let's go ๐!
#Java13
comes out tomorrow and it contains "JEP 350: Dynamic CDS Archives". That makes application class-data sharing more usable by letting you create an app class-data archive during a regular program run.
I updated my post on AppCDS to reflect that:
Will Java get if/else and try/catch expressions or union types? Why are there no named arguments or mutable records? What about ML, AI, and gaming and when will Valhalla land?
I asked
@BrianGoetz
these and more of your questions:
How We Got the Generics We Have
(Or, how I learned to stop worrying and love erasure)
by
@BrianGoetz
After 18+ months, I finally got around to read this one and it's really informative. Here are the closing arguments to what pushed Java to erasure. ๐งต
#ProjectValhalla
is all about performance?
That's what I thought: It gives us user-defined primitives with the resulting great performance and that's mostly it. But in this conversation, I learned how it is much more than that: It aims to overcome Java's original sin. ๐งต
1/9
My conversation with
@BrianGoetz
about the current state of
#ProjectValhalla
- Java's original sin, unifying the type system, expanding generics, current work, the project timeline, and more:
There's a third cool thing that JEP 406 () brings to
#Java17
: guarded patterns!
But... isn't this just like common &&? Why reinvent that wheel? Because it makes patterns more expressive and coding with them more flexible. Here's how!
1/7
The list of big features
#Java20
finalizes is rather short: . (That was it already. ๐ฅฑ) All 20 improves is security, performance, tools, regex, Unicode, and all previews.
Maybe worth a closer look after all?
("This thread should've been a blog post." )
My conversation with
@BrianGoetz
about the current state of
#ProjectValhalla
- Java's original sin, unifying the type system, expanding generics, current work, the project timeline, and more:
#Java17
is around the corner, but not much changed for the module system since
#Java11
. If you want to learn all about it, check out my book The Java Module System.
Only today, you can save 42%:
Does
#Java22
kill build tools? ๐ณ
Of course not, but it does push their use back a bit and in the right circumstances, that's very good. I explain what I mean by that in the latest Inside Java Newscast:
What makes Java *Java*? Why is it so well-suited to writing safe, useful, performant, and maintainable code?
In "The isthmus in the VM" (), JVM architect John Rose describes 16 core Java principles that answer those questions. Here they are (verbatim). ๐งต
You think Java is slow? Cumbersome? Good for serious software but sucks for scripting, exploration, education? Well, kinda ๐คก... No, wait, it's gotten so much better! ๐
Here are 10 things that make Java quicker than you think.
(Code and many links: )
After an eventful September, I'm taking two weeks off. On my way to Vienna now, then onwards towards Brasov in Romania for 12 days of hiking in the Carpathian Mountains. ๐๐ง
So no Java tweets during that time but probably crappy phone pictures of beautiful landscapes. ๐
"What is the best unknown feature of
#Java
?"
Great answer by Anabadyo Das:
1. Stamped Locks
2. Concurrent Adders
3. Parallel Sorting
4. New Date API
5. Controlling OS Processes
6. Exact Numeric Operations
7. Secure Random Generation
8. Optional
What happened recently in JDK development?
Amber:
* Pattern Matching for `switch`
* Array and Record Patterns
* Primitive Type Patterns
Valhalla:
* Primitive Objects
* Unifying Basic Primitives with Objects
More in
#JDKNews
#2
:
What is OpenJDK?
Can you download it?
Does it have LTS?
Is it dangerous for your kids?!
Answers to those and more questions in the latest Inside Java Newscast:
Happy
#Java21
release day, everybody! ๐ฅณ
I hope to see you all later for our live stream (13:00-21:00 UTC / 15:00-23:00 CEST):
Until then, I wanna find out: What finalized feature are you looking forward to the most to put into production?
Q: How do you get/add/remove the first/last entry of a list, deque, sorted set/map, or any other collection with encounter order? How do you iterate in reverse order?
A (on
#Java20
): Inconveniently ๐ to not at all ๐ ๐พโโ๏ธ.
A (on
#Java21
): Easy! ๐
Let me show you how! ๐งต
I'm sure you've encountered the annoying situation where you chain constructors but can't smoothly call the right one with `this(...)` or `super(...)` because you need to do work before, which you can't: no statements before this/super!
Behold JEP 447:
When it comes to using switch in modern Java, there are three decisions to be made:
* colons or arrows?
* statement or expression?
* labels or patterns?
In my new blog post, I examine each decision to find out how to best use modern switch.
Now that Loom's virtual threads are merged and ship with
#JDK19
, what can you do to prepare your code base? Here are 5 things to prepare and keep in mind:
Who's hungry for
#JDK18
?
* pattern matching refinements
* changes to vector API and foreign function & memory API
* simple web server
* IP address resolution SPI
* UTF-8 by default
* more
All about that in the latest Inside Java Newscast:
If on `git push`, you getโฆ
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
โฆit's because GitHub updated their RSA SSH host key. Fix:
ssh-keygen -R
ssh-rsa $KEY=
Details and $KEY here:
Last week I asked for sources on how the JVM works under the hood, so I could finally understand (some of) its magic ways. I got a lot of helpful replies and want to share them here.
Let's start with books. There seems to be no definitive guide, but many good sources.
1/6
void main() {
println("Hello, world!");
}
Latest Inside Java Newscast goes into the proposed on-ramp โ๏ธ that requires programming/Java beginners to learn way fewer concepts before getting started.
Amber, Galahad, Leyden.
Lilliput, Loom, Panama, and Valhalla.
What happened in these
#OpenJDK
projects in 2022 and what will be worked on in 2023? And why am I such a fanboy? ๐๏ธ๐ฉ A thread. ๐งต
(If you prefer video, check the latest Inside Java Newscast: )
If you're interacting with native code from Java, you need to know about Project Panama. I talked with its lead Maurizio about:
* new APIs and jextract
* comparisons with JNI and Unsafe
* interaction with Valhalla
* platforms
* timeline
* much more...
Pattern matching in switch will have its third preview in
#Java19
. It comes with two changes:
* guarded patterns (`&&`) are out; `when` clauses are in
* `null` needs to be handled by a specific `case null`
More in the latest Inside Java Newscast:
Java's future is stock-full of great features but it doesn't come for free. A few technologies hold Java back and will be removed - in the latest Inside Java Newscast I go over all of them with advice for what you have to do to get your code bases ready.
One of my favorite IntelliJ keyboard shortcuts:
"Rollback lines" (Ctrl+Alt+Z for me)
Reverts the hunk that the cursor is currently in. Glorious to quickly undo local experiments.
What's your IDE shortcut tip?
From compact record constructors to pattern matching, from generic wildcards to chaining predicates and comparators, from jpackage to jlink - here are 11
#Java
tricks handpicked from . ๐งต
(Musical version of this thread: )
0/11
Remember, if you implement `equals` with `instanceof` you *must* make either `equals` or the class final!
Otherwise, subclasses can override `equals`, which will usually break the symmetry or transitivity requirements of `equals` and lead to nasty bugs.
Java releases and language features:
#Java8
, after 3 years of development:
* lambdas
* default methods
#Java9
, 3.5 years later:
* module system
* private interface meth.
* try (resource)
* <> on anonymous classes
#Java13
, 2 years later:
* var
* switch expressions
* text blocks
Do you dream of "value types" in Java? So do I! Hence I was thrilled to see that Project Valhalla is slowly coming out of exploration with two draft JEPs.
Here's what they currently propose. ๐งต๐๐พ
(If you prefer video: https:/www.youtube.com/watch?v=WBvTilbh8S0&t=344s)
1/10
Learn all about
#Java17
from the horse's mouth as it comes out (๐คฎ๐ด ๐) at the free
#OracleDevLive
on Sept 14th (1700-2400 CEST) and 16th (1000-1700 CEST).
We'll have hands-on labs,
@venkat_s
,
@pressron
, yours truly, and much more! See you there:
Yesterday, Loom officially submitted JEP 425 - the proposal for virtual threads.
Just now, we published Inside Java Newscast
#23
, which dives deep: scheduling, (un)mounting, capturing, pinning; observability, and what you can do for optimal scalability!