Darwin's Theories Blog

New Theories for a New Time

JavaOne Back From The Dead?

2024-03-19

Today, 2024-03-19, was marked by two important Java items:

  • The full public availability of Java 22, a release with a lot of upgrades;

  • The announcement that there will be a JavaOne event in March, 2025, to mark Java’s thirtieth birthday and the release of Java 24, which we expect to be an LTS release incorporating many of the features that are in Preview or Incubation in Java 21 and 22.

Java 22 contains only a few final language features, but many important ones including "String templates" a.k.a. "expression evaluation in Strings". Whatever you call it, other languages have had it for years, and I’m glad to see it coming to Java. Instead of:

	var message = "Min Temperature " + temp + scale + " occurred at " + time;
or
	var message = String.format("Min Temperature %f%c  occurred at %s", temp, scale, time);

you can now just write:

var message = STR."Min Temperature \{temp}\{scale} occurred at \{time}";

This new form keeps the string and its components together more clearly, while avoiding the error-prone string concatenation. STR is an implementation of the new StringTemplate.Processor interface, and is imported automatically, like classes in java.lang. If you want to use printf-like codes to have more control over formatting, there is another formatter, called FMT. This uses the same formatting language as String.format(), but has to be imported explicitly. String Templates will be written up in more detail in the fifth edition of my Java Cookbook.

JavaOne, as Java old-timers know, was an annual Java conference held annually by Sun Microsystems. After Oracle swallowed up Sun, the conference became irregular, then ceased for a while, then got rolled into OracleWorld, then discontinued again, held once, then "paused" again. Now, Oracle has announced that it will be back for 2025, but in March rather than the traditional fall timeframe. You can sign up for updates at the traditional URL. As mentioned, this JavaOne is to celebrate thirty years of Java, and will coincide with the release of Java 24. Few details are out yet: the dates are March 17-20, and the location is said to be the Oracle Campus in Redwood City, California. Beyond that, we’ll have to wait and see. Hope to see many of you there!

Tags