The I Programmer Java 2023 Recap
Written by Nikos Vaggalis   
Thursday, 28 December 2023
Article Index
The I Programmer Java 2023 Recap
Towards JDK 21
Support for Virtual Threads

Despite JDK 20's release, vendors had been still picking up version 17. In May, AWS adopted Java 17 so that AWS Lambda functions could now, as part of the Amazon Corretto JDK implementation, use all the new and useful language features and the performance improvements introduced in Java 17.

CRaC

Then in June, Azul released its own version 17 built with CRaC embedded. But what is CRaC and why do we need it?

The JVM is notorious for its hefty requirements in startup and warmup times. The main reason for the slow startup is that it takes much time to load, link, and initialize classes. Of course, we are talking micro-seconds here, but the delay can make a difference when trying to spin VMs on the Cloud and run Microservices. There are ideas for speeding things up and CRaC is one of them.

CRaC stands for Coordinated Restore at Checkpoint. It is an API that helps to coordinate the JDK and an application's resources under a checkpoint/restore mechanism.
It allows applications to, for instance, close open files, dump their cache, and snapshot the required state for them to come alive when restored back.

As such the primary aim of the project is to offer a standard mechanism-agnostic API to notify Java programs about the checkpoint and restore events, thus unlike AOT retaining the full power of JIT compilation and leveraging the checkpoint mechanism.

Projects with CRaC support already are Micronaut and Quarkus while there's a modification of Tomcat that enables CRaC for Spring Boot applications.

Jakarta vs Spring

Talking about frameworks, Spring and the like, it was time to settle the argument of Jakarta vs Spring once and for all. An attempt to do that was initiated by a great webinar by Antoine Sabot-Durand streamed as part of the JConference, called "Has the J2EE vs Spring Infinity War reached an End Game? A short history of Java for the enterprise".

Antoine is a Java Champion. He is also the CDI 2. 0 spec lead, involved in Microprofile and various projects linked to CDI ecosystem development and thus Jakarta EE. His talk was driven by his recurrent observation, when wearing his recruiter hat, that most Junior developers were familiar only with Spring, ignoring J2EE altogether. While that didn't pose a hurdle for being hired, it still looked off in that J2EE, and its later incarnation Jakarta, are an integral part of the Java ecosystem, and ignoring that part while completely living in the Spring world didn't paint the full picture.

If you want to delve into it, check IProgrammer's detailed report Jakarta vs Spring - The War Goes On, but to cut a long story short the finding was that in the end, the fierce competition between Spring and Jakarta profited the whole Java ecosystem; they brought it up to par, and even beyond ecosystems that had capitalized on Java's late entry into the Microservices and Cloud native era.

On that front, Jakarta rushing to modernize to catch up with Spring, got its own Project Initializer too, and it was about time. Spring had it for ages, and was one of its advantages over Jakarta. Would the new initializer turn the tide in Jakarta's favor?

As Reza Rahman, a committer on the Eclipse Starter for Jakarta EE project, a project lead for Eclipse Cargo Tracker, and a program manager at Microsoft, puts it :

There’s been a longstanding perception of Jakarta EE and Java EE that it’s kind of impenetrable and hard to get into. And that was true to a certain extent for some years. Java came out nearly thirty years ago, and some of the runtimes based on it are nearly as old. Many of the runtimes also had convoluted installation procedures, and it takes several steps to get them installed and running on a machine.

With the starter project, applications can choose the Jakarta EE certified runtime. In its absence, there isn’t anything to help developers to get started using Jakarta EE. If they had the necessary knowledge and were very motivated, they could figure it out. But it created a lot of unnecessary friction. The project attempts to address these issues by basically allowing a newcomer to get started with Jakarta EE quickly and easily — with a runtime of their choice and painless on-boarding in mind.

JDK 21

September 2023 and a big milestone for Java arrived. The GA of JDK 21. That release marked a milestone for the language; readied for the cloud native era and modernized enough to make it easy for beginners to pick up.

JDK 21 goes over the top comprising of fifteen JEPs, including the final versions of Record Patterns (440), Pattern Matching for switch (441), and Virtual Threads (444):

430: String Templates (Preview)
431: Sequenced Collections
439: Generational ZGC
440: Record Patterns
441: Pattern Matching for switch
442: Foreign Function & Memory API (Third Preview)
443: Unnamed Patterns and Variables (Preview)
444: Virtual Threads
445: Unnamed Classes and Instance Main Methods (Preview)
446: Scoped Values (Preview)
448: Vector API (Sixth Incubator)
449: Deprecate the Windows 32-bit x86 Port for Removal
451: Prepare to Disallow the Dynamic Loading of Agents
452: Key Encapsulation Mechanism API
453: Structured Concurrency (Preview)

From those JEP's one that stands out was JEP 445 "Flexible Main Methods and Anonymous Main Classes" . It's no secret that Java is not the favorite language of Coding Bootcamps. Now this OpenJDK proposal tries to change that by reforming the language's syntax itself.

Bootcamps and College Programming 101 try to teach languages that are approachable to beginners such as Python and Javascript, which are easy to begin with and without having to get too deep initially, under a scheme of "show first and explain later". Then they're also easy to set up in order to run the first programs as fast as possible.

In contrast, to start writing code in Java, even a simple "Hello World" program

public class Main {

public static void main(String[] args) {
  System. out. println("Hello World");
  }

}

requires you to understand the concept of Classes, Static modifiers, String data type, arguments and the need for method main. Then you need to know that System. out. println is a method that prints text to the console, with the "System" class being part of the Java standard library which provides access to the system resources, such as the standard input, output, and error streams. Just mindblowing for a beginner!

This had to change if you wanted to attract fresh blood to the aging Java developer community. Now the new philosophy goes something like 'what if try to remove as much cruft as we can so we don't give a hard time to novices?'. And that is what JEP 445 "Flexible Main Methods and Anonymous Main Classes" does. According to it, the "Hello World" example above would become as simple as

void main() {
  System. out. println("Hello World");
}

omitting String[] and the Static modifier as well as making the Main class declaration implicit. Well that leaves "System. out. println" intact but at least taking the rest off can be considered as an improvement.



Last Updated ( Thursday, 28 December 2023 )