Tales from the jar side: Java 19 is All Previews, more Chess drama, the NFJS event in Boston, Triton is Fabulous, and other tweets
My wife thinks it's weird I stare at the window during a heavy rainstorm. It would be a lot less weird if she would just let me in.
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of September 18 - 25, 2022. This week I mostly spent working on the next beta of my Mockito Made Clear book, and spoke at the NFJS event in the Boston area.
Regular readers of this newsletter are affectionately known as jarheads, and are far more intelligent, sophisticated, and attractive than the average newsletter reader. If you wish to become a jarhead, please subscribe using this button:
As a reminder, when this message is truncated in email, click on the title at the top to open it in a browser tab formatted properly for both the web and mobile.
Java 19 is Released
Ever since Java 10 was released in March, 2018, Java has been on a six-month major version release schedule, meaning a new major version comes out every March and every September. That means this September (the 20th, to be exact) saw the release of Java 19. The Oracle people and related team members announced it with great fanfare, accompanied by tweets, videos, and more.
Here’s the thing, though. While several JEPs (Java Enhancement Proposals) were included, all the significant ones were in preview form. Here’s the list, as shown on the Java 19 page at openjdk.net.
Out of 7 JEPs, four are previews and two are incubators, which means they’re a long way from general availability. The only one that was finished was the port to Linux with a RISC chip, which is great, but affects only a handful of people and doesn’t change the way you write code at all. In other words, unless you are eager to try out features that may change significantly, there’s nothing here at all.
Most of the excitement, such as there is, is about the first appearance of virtual threads, a product of Project Loom, along with the related topic of structured concurrency. Here’s the first example listed in the JEP:
It’s nice that you can launch 10,000 virtual threads with no fear of locking up the operating system. I’m glad that’s on its way, and maybe the idea of having threads that cost almost nothing to run will change how we write code, but I have a couple of issues with getting involved now.
First, this is the first preview, and I’m quite confident there will be at least one, and probably two, and maybe three more. At six month intervals for the releases, that means a general availability release is at least a year and probably 18 months away, and then you have to wait for the community to adopt it. Given that the Java world is largely split between versions 11 and 8 at the moment, we have a long time before anybody really needs to worry about actually using any of this.
Speaking of that, since most companies don’t want to update their Java deployment environments every six months, the Java team designates certain releases as LTS (Long-Term Support) releases. Up to now, those have come out every three years, with the most recent being Java 17 from last September. The result in the community is that non-LTS releases are almost totally ignored. This frustrated the Java team so much that they’re planning to move the LTS period to only two years, which means the next LTS release should be Java 21, scheduled for next September. So if virtual threads and structured concurrency do three previews instead of two, they’ll miss the next LTS release, which will probably delay their adoption for another two years, at which point I’ll probably be safely retired.
Second, if I want to play with virtual threads that are already implemented, Kotlin has had coroutines since version 1.3, which came out in October of 2018. I spent a lot of time with coroutines while writing my Kotlin Cookbook, and I can tell you that while it’s really a helpful technology, just because the code looks simple doesn’t make it simple to understand. They also have had structured concurrency for years, and even with that I still get very confused about coroutine cancellation and exception handling. Probably the biggest lesson I’ve learned is that coroutines work best when they’re incorporated into libraries that I can just call, rather than writing my own low-level code. I therefore expect the Java implementations to evolve the same way.
I’m glad Java is upgrading like this, but pardon me if my enthusiasm is a bit restrained at the moment.
As a final note, I was hoping that pattern matching for switch would be released by now, because it plays very nicely with sealed classes. As you can see, however, that’s undergoing yet another preview, with yet another change in syntax. Also, they introduced the idea of pattern matching with records, which is a lot like Kotlin’s destructuring, but again it’s only a preview. So again it’s all wait and see. I’ll upgrade because I teach this stuff, but I’m only hoping that the community will move to Java 17, at least until the next LTS version come out a year from now.
Chess Update, Apparently A Continuing Series
My last couple of newsletters contained summaries of the ongoing controversy in chess involving World Champion Magnus Carlsen and young Grandmaster Hans Niemann. The triggering event came during the Sinquefield Cup a couple of weeks ago, when Magnus lost to Niemann in an unusual opening (Niemann claimed it was a “miracle” he’d reviewed that variation just that morning) and subsequently dropped out of the tournament without an explanation. Speculation immediately arose suggesting Magnus believed Niemann may have cheated. Hans in subsequent interviews denied cheating in any live tournaments, but admitted to doing so in a couple of online tournaments when he was younger. Given that he’s still only 19, the word “younger” has a somewhat different meaning when he says it.
This week, both players were committed to an online rapid tournament called the Julius Baer Generations Cup, which included a wide range of older and younger players. The organizers explained that their qualification rules mandated that Niemann be invited, even though they knew Magnus wouldn’t be happy about it.
A rapid time control meant the players would each have 15 minutes for the entire game, with a 10 second increment (10 seconds are added to your clock after each move). Magnus is one of the best rapid players in the world, but that’s not terribly surprising given that he’s one of the best players in the world period. The first two rounds of the tournament were a round-robin among the sixteen players, with the top eight qualifying for a series of four-game matches each day leading to the finals, which were two days of four-game matches.
Magnus was scheduled to play Niemann in the third round on the first day. Since he still hadn’t said anything publicly, people were hoping they’d just play their game and get it over with, so the controversy could be dealt with behind the scenes.
What happened was quite different. Niemann, playing with the white pieces, opened with 1. d4, Magnus replied 1. … Nf6, and Niemann then played 2. c4. Then Magnus resigned and disconnected. Really.
Nobody expected this, least of all the commentators:
It turns out that in the online system they were using, you have to make at least one move before you resign, which at least explained why Magnus showed up. Clearly, however, he was unwilling to play Hans at all.
Some worried that this might make it harder for Magnus to make it out of the qualifiers, but he then went on one of his most dominant streaks ever, destroying everyone with 10 wins, 4 draws, and only that single loss. He finished first in the round-robin section by a wide margin.
The remaining suspense, however, was where Niemann would wind up. The rules said that after the round-robin, player 1 would match up with player 8, player 2 with player 7, and so on, so there was a chance they’d have to play again, and this time a resignation would cost Magnus the entire tournament. As it turned out, Niemann played well and wound up third, meaning the only way he could face Magnus was if they both made it to the finals.
The uncertainty only lasted a day. Niemann played well, but ultimately lost to Quang Liem Le from Vietnam, and was therefore out. Magnus lost his first game to Levon Aronian, but then went on a tear, won three straight, and was never really threatened again. He beat Aronian, then young Vincent Keymer, and then faced 18-year-old Arjun Erigaisi in the finals, one of the new generation of brilliant kids from India. Magnus dominated him on both days of the finals. It wasn’t even close. Meanwhile, more and more people are hinting that there’s a lot more to say about Niemann, though evidence is always sketchy. Expect more about that soon.
At least a few funny tweets came out of the tournament. First, this one:
Yup, that’s pretty much what happened. As far as the chess world was concerned, BOOM. Once again chess made the popular press, though this time I’ll only link to this article at The Defector if you’re interested.
The next good tweet was from a former challenger for the world title:
The “fighting index” is a measure of how hard a player tends to fight for a win rather than settling for a draw. I wonder who that “friend” was? (Snicker)
Finally, this cracked me up:
(That’s the position when Niemann played 2. c4 and Magnus resigned.)
Magnus promised he’ll release a statement this week. That should resolve all the controversy, right? No, probably not. In fact, not a chance. I’ll probably have to say something in next week’s newsletter as well, so stay tuned, same Bat-time, same Bat-channel.
No Fluff Just Stuff Returns
The NFJS tour resumed live events starting back in April. Last year they held a few live events, like UberConf, but mostly the attendance numbers didn’t warrant going live on a regular basis. This year a few of the events have been postponed, but several were held live. This week, we met in Wakefield, MA, for the so-called New England Software Symposium.
I gave five talks: three Friday afternoon and two on Saturday. I really enjoyed seeing everyone again. While I don’t mind teaching remotely — I shouldn’t, given that that’s been the bulk of my business the last couple of years — there’s nothing like interacting directly with people.
As an aside, here’s my favorite related joke:
I’m really glad to see you all here. I’m much funnier live, because most of my jokes aren’t remotely funny. (Rimshot)
My talks were:
Fri 1:15 PM EDT Property-Based Testing: Concepts and Examples
Fri 3:15 PM EDT Java Testing Part 1: JUnit Jupiter and AssertJ
Fri 5:00 PM EDT Java Testing Part 2: Mocks, Stubs, and Spies with Mockito 4
Sat 1:30 PM EDT Spring Data and the Java Persistence API
Sat 3:15 PM EDT Key Gradle Concepts And Practices
They all went well, though the Spring Data talk went too long. I have to find a way to cut that down to just the highlights. I’ll probably expand the associated virtual workshop (happening this week, as it turns out) into two separate classes next year.
My conferences for the rest year are ApacheCon, October 3 - 6, in New Orleans, then JavaOne, October 17 - 20, in Las Vegas, and finally the NFJS event in Austin, TX, in early November.
Miscellaneous
Neptune Like You’ve Never Seen It Before
NASA released a new image of the planet Neptune, taken with the James Webb Space Telescope (JWST):
The image on the left was from the Hubble Space Telescope, but it strongly resembles the picture taken by the Voyager 2 probe, which finished a grand tour of the outer solar system (Jupiter, Saturn, Uranus, and Neptune) back in 1989 on its way into interstellar space. The image on the right from the JWST is in the infrared, and highlights Neptune’s rings, which Voyager saw but are very faint in visible light.
The JWST image also included many of Neptune’s moons, including Triton, which shows up looking fabulous:
This led to an excellent tweet about the moons:
You go, Triton. You be you. :)
Brand Tweets FTW
Most companies have twitter feeds, and most of them are boring, with some exceptions. When Southwest Airlines partnered with Guitar Center and gave away ukuleles on a flight to Hawaii, they tweeted:
Amtrak saw this as an opportunity and jumped on it:
Very clever. I’m guessing that no, by the time they arrived in Honolulu the passengers were probably not pros at the ukulele.
A Triple Play
Baseball season is winding down, but this happened:
Just your routine 6-4-3 triple play. Nice.
It reminds me that when I was an undergrad, as a junior I was captain of our C-league softball team (we were C-league because there was no D-league). In one game, our opponent had players on first and second with nobody out, when the batter hit a fly ball to short center. In softball, we had a short-center fielder (meaning someone playing in shallow center, though yes, they were also short, making them a short center-fielder) who ran in and caught the ball. That was the first out. Their momentum caused them to land on second base before the runner who started on second realized what was going on and tagged up, so that was the second out. Then, as they were coming to a stop, the runner coming in from first base (who shouldn’t have been running, but hey, this was C-league) ran into them, which was the third out. Triple play, almost completely unintentionally.
We all stood around staring at each other for a minute before we realized the short-center fielder had accomplished an unassisted triple play and we could bat now. It was the first, and only, triple play in the history of our team, and probably in the entire history of C-league intramural softball, though we have no way of checking that.
As I recall, we actually won that game, which was our first win in two years. It happened when we loaded the bases in the bottom of the last inning and sent Anna Quaadgras to the plate, who was from Holland and had never played baseball in her life. We told her not to swing and just hope for a walk. (We were tempted send her up to the plate without a bat, but that seemed a bit too much.) She did in fact draw the walk, which brought home the winning run. We carried her off the field on our shoulders in the resulting celebration.
I still remember that partly because wins were so rare for us, but also because I was team captain that year. That meant I got to bat first and play second base every game, but didn’t mean much else. I remember once in actual Little League in junior high, I hit a hard grounder to short, which the shortstop bobbled, picked up, dropped transferring it from his glove to his throwing hand, bobbled again, and finally threw to first, and I beat out the throw by a step. My friend who came up to coach first couldn’t help pulling me aside and asking, “Were you just faking it, or are you really that slow?”
I was offended and would have replied, but I was still breathing too hard after practically flying to first base.
All I can say is, it’s a good thing I never had to rely on my baseball skills for anything important. There’s a reason the Red Sox still haven’t called. Besides, Major League Baseball has a horrible bias against players who are old, slow, small, and have no discernable baseball skills, but what can you do?
Have a good week, everybody. :)
(Thanks once again to my friend Bill Fly for the link to https://instantrimshot.com/ for the rimshot added to the audio recording.)
As a reminder, you can see all my upcoming training courses on the O’Reilly Learning Platform here and all the upcoming NFJS Virtual Workshops here.
Last week:
New England Software Symposium, the NFJS live event in Wakefield, MA.
This week:
Spring Data and the Java Persistence API, an NFJS virtual workshop
Java Testing, Part 2: Mocks, Stubs, and Spies with Mockito, ditto again