Revisiting Java for Shell Scripting

Around 6 years ago, I wrote about using Java for shell scripts. It was a hacky and fragile way to convert some Java code into a shebanged file containing the content of a Jar file. However, Java evolved quite a bit since that article, so it’s time to look at it again.

Looking at Java 21: Generational ZGC

Java is (in)famous for its Garbage Collection. It’s one of its main strengths, but it can also be a source of many headaches. An additional garbage collector was introduced in Java 11 (JEP 333), a low latency/high scalability GC called ZGC. And now, with Java 21, it has evolved into a generational GC (JEP 439).

Looking at Java 21: Record Patterns

Pattern matching is a declarative and composable approach that creates more powerful and expressive code for data structure navigation and processing. Java 16 added pattern matching for the instanceof operator (JEP 394), and we looked at pattern matching for switch in this series before (Switch Pattern Matching. Today, it’s time to take a quick look at another kind of pattern matching: Record Patterns (JEP 440).

Looking at Java 21: Feature Deprecations

Even though Java is one of the most backward-compatible languages and environments I’ve ever worked with, there’s always the possibility of feature deprecations and even removals. Java 21 will deprecate two features, so that’s what we’re looking at today.

Looking at Java 21: Switch Pattern Matching

The switch control structure has quite an evolution lately since its inception. First, there were switch expressions (JEP 325, 354, 361). And now, we get pattern matching for switch statements and expressions!