How to Build Java Applications Today: March 15, 2021
Java record serialization, JRebel 2021 Java Technology Report, Spring Native beta announced, Micronaut 2.4 released, and new TypeScript handbook.
This is issue #27 of my weekly newsletter “How To Build Java Applications Today” - for Java developers, by a Java developer.
Well, tomorrow’s the day that Java developers worldwide have been waiting for: March 16, 2021. That’s the day that I’ll give my talk at JavaLand 2021, Germany’s biggest Java conference!
Ha, just kidding. Well, I do talk at JavaLand. But Java developers are really waiting for Java 16. So there’ll be an avalanche of “What’s new in Java 16?” articles. And inevitably, I’ll pick one for next week’s issue. In the meantime, wish me luck with my talk!
Quote of the Week
Speed is useful only if you're running in the right direction.
Inside Java: Record Serialization
Last week, I wrote about Project Valhalla and inline types. If you squint, they look like “immutable value classes” from Project Lombok. But their purpose is different: They speed up memory access by turning multiple objects into one flat object.
Well, this week we’re talking about the real immutable value class in Java: Records. With Java 16, they leave preview status. And according to Oracle, they are easy to understand, have no magic, are more secure, and offer better performance. How’s that possible?!
Java uses reflection to serialize and de-serialize Java objects. Records, on the other hand, are immutable and declare their properties. So Java can uses getters and the constructor here to serialize and de-serialize records. That makes the “serialize magic” vanish, is more secure and better-performing. And with the constructor, there’s now just one place for us to check if the object is valid. That’s the “easy part”!
JRebel 2021 Java Technology Report
Another year, another technology overview from JRebel, makers of the “instant class reloader” of the same name. This year, nearly 900 Java developers replied. So, what’s the state of Java technology?
It’s sad: Java 8 is the “programming language of choice in their main application“ for a whopping 69% of respondents. That’s more than last year’s 58%! Even “Java 7 or older” grew from 7% to 15%. My only explanation is that a much more conservative crowd replied this year. Will “old Java” ever go away?! Seems like it won’t anytime soon. 😒
Spring Boot rules with 62%. So the lack of native image support hasn’t curbed the enthusiasm out there much. Number 2 is somebody that wasn’t even on my radar screen: DropWizard. Quarkus sits at 6%, and Micronaut at 4%. And in what can only be described as a gut punch for open standards, Java/Jakarta EE is now part of the “Other” framework section (which has 17%). Ouch.
IntelliJ is the most popular IDE at 65%, followed by Eclipse with 48%. I thought VSCode had a strong showing at 27%. IntelliJ and Eclipse, get ready for battle with Microsoft!
Read the full report for more juicy technology stats.
The Empire Strikes Back: Spring Native Beta Announced
Talking about lack of native image support in Spring: That’s about to end this fall. Spring announced the Spring Native Beta! And yes, I had to go there with a Star Wars reference. So how does Spring Native work? And what can it do today?
In true Spring fashion, Spring Native is just a dependency you add to a Spring Boot 2.4 project on start.spring.io. It uses GraalVM under the hood, just like everybody else does. Unfortunately, you don’t see there if another Spring dependency isn’t ready for Spring Native: You have to look into the
HELP.md file of the generated project to find out. Really, Spring? You can’t tell me when I add the dependency on start.spring.io? It’s not like you don’t know at that point already!
Anyhow, at least it works with both Maven and Gradle. And if all your dependencies work with Spring Native, you’re good to go! Then
mvn spring-boot:build-image or
gradle bootBuildImage is all that stands between you and a walk. Well, a long walk, apparently, because turning your Spring Boot project into a native image takes a long time. Let’s hope you don’t find out in the end that your logger configuration doesn’t work with GraalVM! See last week’s “Not for the Faint of Heart: GraalVM Native Images“ bookmark for the gruesome details.
Micronaut 2.4 Released
Working hard to increase its microscopic market share (JRebel pegged it at 4% - see above), Micronaut released version 2.4. “Microscopic”? I’m sorry, Micronaut, but you brought this onto yourself: You had to name yourself “Micronaut”!
Somewhat surprising, the announcement starts with minor annotation name changes. So supporting Java records (see this week’s first bookmark) seems to be the biggest news here. Or maybe it’s initial support for Oracle Coherence Community Edition? And why aren’t these two items at the top? You know, ahead of the thrilling “Micronaut now supports ‘jakarta.inject' annotations as an alternative to 'javax.inject'“? Your guess is as good as mine…
If you want to dig in even deeper, then the “What’s New?” section describes it all.
Over the Fence
New TypeScript Handbook
Karsten Silz is the author of this newsletter. He has been a Java developer for 22 years.
He grew up in East Germany, behind the Iron Curtain. He wrote his first BASIC program on a Sinclair Spectrum ZX81 in 1984 and never looked back. He got a Master's degree in Computer Science from the Dresden University of Technology in 1996.
Karsten has developed software in five European countries and the U.S. since 1996. In 2004, he co-founded a software product start-up in the U.S. The product reached an 80% market share in the North American cable TV industry. During power outages, it protected TV, Internet, and phone services for 50 million households. Karsten led product development for 13 years and left after the company was sold successfully.
Since 2017, he has worked as a full-stack Java contractor for web (Angular) and mobile (Flutter) in Germany and the U.K. He co-founded the SaaS start-up "Your Home in Good Hands" as CTO in the U.K. in 2020.