Tales from the jar side: JVM Weekly is great, AI tools for Java devs, Spring office hours, and the usual assortment of toots and skeets
My printer ran out of paper, so I filled it with strawberry preserves. Now I have a paper jam. (rimshot)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of August 13 - 20, 2023. This week I taught a New Features In Java course on the O’Reilly Learning Platform, and gave an NFJS webinar on Practical AI Tools for Java Developers.
Regular readers of (and listeners to, and now video viewers of) this newsletter are affectionately known as jarheads, and are far more intelligent, sophisticated, and attractive than the average newsletter reader (or listener, or viewer). 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 to open it in a browser tab formatted properly for both the web and mobile.
JVM Weekly
Over the past few months, I’ve been reading an excellent newsletter called JVM Weekly. It’s written by a developer named Artur Skowronski, who I’ve come to admire.
As you can probably judge from the name of my newsletter*, I spend a lot of time in the Java world.
*For those who don’t know, the term jar stands for Java Archive, which is basically a zip file for compiled Java code. It’s also the standard way to distribute Java libraries. Just FYI.
So does Artur. JVM Weekly describes itself as “a newsletter that provides weekly updates on news, trends, and best practices related to Java Virtual Machine (JVM) and its ecosystem.” You might expect from that description that our newsletters have a lot of overlap. I certainly would have. As it turns out, that isn’t true at all.
JVM Weekly is much more focused on parts of Java that I take for granted. While I am aware of new features being added to the language and know where to find the JEPs (Java Enhancement Proposals) so I can read about them and present them to students, JVM Weekly digs into the details of how they’re implemented, what alternatives are available, and more. I tend to ignore incubating and preview features, but Artur digs into them in detail. While I have a background in alternative JVM languages like Groovy and Kotlin, Artur is much more interested in Scala, though we both follow Kotlin. He cares about frameworks like Quarkus, while I spent prefer both Spring, Grails, and Micronaut. I use the JVM mostly as a black box, caring more about teaching devs how to work with it than how to optimize performance. He really gets into those performance details.
The distinctions may not sound like a lot, but the result is I find our skills are quite complementary. I learn a lot from his newsletter every week and really look forward to it.
Why am I mentioning this now? A couple weeks ago in JVM Weekly he made a few Hitchhiker’s Guide to the Galaxy references and lamented the fact that he was only on the waiting list for the AI Assistant tool from JetBrains. I added a comment that praised him for the jokes (I thought they were funny, but you know the caliber of jokes I tend to include here, so take that into account) and told him he was going to enjoy the AI Assistant, which I use all the time, especially for generating git commit messages.
This week I was happily surprised to see him not only subscribe to Tales from the jar side, but actually recommend it. I already was a subscriber to his newsletter, so I made sure to recommend his, and I’m talking about it here. I don’t know if that’s why I got a nice uptick in subscribers this week or not*, but either way, I’m happy to recommend him and his newsletter. Of course, this all assumes you’re reading my newsletter for the Java content. If not, hey, no prob. I’m just happy to have readers every week.
*Probably part of the gain is a holdover from what I’m calling the Venkat Effect. I hosted Venkat Subramaniam on a Live Stream a couple weeks ago and am still gaining subscribers as a result. See also the Shorts here and here.
His gags are pretty funny. A joke from his newsletter last week shows the difference between science and engineering:
Incidentally, JVM Weekly is currently free, though I noted Substack added one of those “Pledge your support” buttons to it. I expect I probably have one as well, though I can’t really check because I’m already logged in when I get here. Interesting to see what that looks like. I plan to stay free for as long as possible, but if I ever add more issues per week, that may change. The Sunday issue has always been free, however, and will stay that way.
AI Tools for Java Developers
On Friday, I gave a (free) NFJS Webinar called Practical AI Tools for Java Developers, which will turn into a half-day training course starting in October. I spent a lot of time this week preparing for that course. Here’s the basic idea:
Most of the existing ways to access AI tools programmatically involve either a set of HTTP links (a REST interface, involving GET and POST requests), or Python code. Available programming examples use Python extensively.
The server-side of much of the Internet, however, runs on Java. If we want to incorporate AI tools into our systems, how are we supposed to do that?
My approach is based on the idea that if an AI tool has a REST interface, then all you need is a Java HTTP Client and a JSON parser and you’re good to go. (Another way to say that is that traditionally the easiest way to integrate systems together is to pass formatted strings around, and that’s really all JSON data is anyway.) In this GitHub repository, I’ve built examples to access ChatGPT via its OpenAI API, Whisper AI (audio to text transcriptions), Stable Diffusion (text to image generation), and Midjourney (via Picogen), all using the HttpClient
API from Java 11+, as well as text blocks, records, sealed interfaces (mostly coming soon), and more features from Java 17.
As a particularly silly example, here’s an image I generated from Midjourney (via Picogen), from the prompt:
Again, see the GitHub repository for the details. Here’s the result:
Yeah, I can see that, more or less, though I’m not sure when Robin got glasses, and that is an awful lot of keys on that keyboard. Still, I’ve seen lots worse.
I also decided this was a good opportunity to create a series of YouTube videos documenting the process. The first one is called OpenAI Tools in Java 17: List the Models:
That videos shows my project setup, how to use the HTTP Client, how to use AI Assistant to map the input and output JSON data to Java records, and listing the available models in the OpenAI API.
That, by the way, led to a problem during the webinar, which fortunately I could fix. When I listed the available models, I used a stream sorted by creation date to show them:
Model{id='gpt-3.5-turbo-0613', created=2023-06-12T12:30:34}
Model{id='gpt-3.5-turbo-16k-0613', created=2023-05-30T15:17:27}
Model{id='gpt-3.5-turbo-16k', created=2023-05-10T18:35:02}
Model{id='gpt-3.5-turbo-0301', created=2023-03-01T00:52:43}
Model{id='gpt-3.5-turbo', created=2023-02-28T13:56:42}
Model{id='whisper-1', created=2023-02-27T16:13:04}
and many more. Part of the video shows how to convert a Unix timestamp (provided by the API) to a Java LocalDateTime
.
Conspicuous by its absence is GPT-4, which I’m sure I used at some point when I first wrote the code. Anyway, when I tried running an example with GPT-4, I got an error. I dug into it after the the webinar, and found that it’s not available for everyone, and certainly not for me at the moment. One message from the company on the support forum suggested you needed to spend at least $1 for them to make it available, and I thought I’d done that, but apparently not, at least not this month:
Of course, that’s just for August. I spent almost a whole penny this week preparing for the webinar. Combined with the $0.19 last month I spent preparing for UberConf and my presentations there, I guess I’m not really racking up the charges very quickly, which I still consider to be a good thing.
Someone in the forums, however, suggested that $1 price wasn’t really a requirement. They said OpenAI is rolling out GPT-4 access and we’ll all get it eventually. I don’t know. I thought I already had it, but apparently not. Hopefully I’ll have it by October when I run my NFJS virtual webinar.
Direct AI Integration from Java
One more thing about the AI integration. As usual, this week’s JVM Weekly had a totally different perspective. Artur pointed out that Meta (you know, Facebook) released their LLaMA 2 (Large Language Model 2, get it?) as an open source project, and there are two GitHub projects for working with it in Java: one called Jlama, and one called llama2.java. Both are far more direct than just driving an existing remote service. I looked at them, and I’ll keep looking at them, but I’m not sure yet what to do with that information.
It would be nice to run the language models locally and train them on your own data, so arguably I should add that to my course. I don’t know, though. That’s very resource intensive and require a lot of data, but maybe I can do a proof of concept. Actually, I’m pretty sure Artur will include some good ideas in his newsletter soon enough. :)
Spring Office Hours
My friend Dan Vega was kind enough to ask me to sit in on his regular Spring Office Hours on Tuesday this week:
In case you’re interested, here’s the link to the replay page. We had a lot of fun. We spent some time talking about Spring, but more talking about my background and how I got into this field, and even about this newsletter. Dan was very gracious.
He and several of my friends are at SpringOne in Las Vegas this week, and I wish them all the best. Hopefully the path of tropical storm Hilary won’t affect them (or their flights) too much.
Toots and Skeets
This sounds about right
I skimmed that too quickly the first time, but then I went back and realized this is an exercise program I could probably get into.
Suddenly it all makes sense
Ah, that’s why it always shows 90% for most of the duration. I get it now.
Banana Wrapper
Makes you wonder how many people failed before the first success.
X marks the downward spiral
Brilliant. Makes you wonder how long they’ve been sitting on that joke.
I’m not going to waste time and energy this week lamenting the demise of Twitter and the idiocy of Elon the Stupid yet again. For example, I’m not going to comment on the incredible pettiness of throttling links away from Twitter (gift link to NY Times article):
I mean, how seriously messed up do you have to be to even think of doing that? And then take real developers off of real project work so they can implement it? Not to mention the Q/A costs, inevitable support calls, and other costs? Really, how big a manbaby do you have to be to both (1) think of something this petty and then (2) decide it’s worth implementing, even though you know people are going to notice and call you out on it?
The answer: really, really petty, and an incredibly whiny, pathetic manbaby with a complete lack of self-control.
I’m also not going to comment on the sheer lunacy of disabling the block button (gift link to Washington Post):
Presumably either he got upset that everyone blocks him, and/or some of his few remaining advertisers got upset instead, but either way, yikes. I liked this statistic:
Even the threat of disabling the block button (which hasn’t happened yet) caused an exodus. Bluesky itself experienced a serious slow down as a flood of new users joined.
It does seem that Elon’s goals are coming into focus:
Yeah, I’m not going to comment on any of that. Aren’t you glad?
I still have a few bluesky invites to give out if you want one. Just remember the ground rules over there:
Seems reasonable.
See Barbie in the original Klingon
I was going to make some Barbie-related Klingon puns, but after staring at that picture for a while, I honestly don’t even know where to start. So of course I asked GPT-4:
Me: I have an image of Worf from Star Trek decked out as Barbie, with long blonde hair and a pink outfit. The caption reads "See the Barbie movie in the original Klingon." I need some Barbie/Klingon puns for it. Got any ideas?
Response:
Certainly! This creative crossover between the worlds of Barbie and Klingon provides a unique opportunity for some clever wordplay. Here are some puns that might fit the theme:
1. BarbieQ: "Join Worf at the BarbieQ, where fashion meets the battlefield."
2. Klingon Chic: "Introducing Klingon Chic, where fierceness meets fabulousness."
3. Bar'bIe: "In Klingon, it's not just Barbie; it's Bar'bIe, the warrior of glam."
4. Warp Factor Glam: "Worf's new look takes fashion to Warp Factor Glam."
5. Bat'leth & Beauty: "Unleashing the power of Bat'leth & Beauty, where elegance meets honor."
6. Kahless Collection: "Dress for success with the Kahless Collection, where every day is a good day to dazzle."
7. Fashion Frontier: "Exploring the Fashion Frontier, one Klingon runway at a time."
8. Qapla' Couture: "Success in style with Qapla' Couture, for the warrior who dares to be different."I hope these puns align with the humorous spirit of the image! Feel free to let me know if you'd like more options or specific adjustments.
Oookay. Mixed quality, but certainly better than anything I thought of, so yeah.
(I do like, “Every day is a good day to dazzle.” Snicker.)
Speaking of Klingons
It’s cloaked, get it? Now that’s the sort of tattoo I could get into, though I imagine avoiding pain violates the whole spirit of Klingons.
But what about Thomas?
Poor Thomas the Tank Engine, neglected again. Or maybe he can’t read. I’m not sure which is worse.
Very clever
If you need a hint, that’s a single crow. What’s the collective noun for crows?
Finally, Caffeine
That’s another hint for the previous image, but that doesn’t make it any less true.
Have a great week everybody!
The video version of this newsletter will be on the Tales from the jar side YouTube channel tomorrow.
Last week:
New Features in Java, on the O’Reilly Learning Platform
Practical AI Tools for Java Developers, an NFJS webinar on Friday
This week:
Reactive Spring, on the O’Reilly Learning Platform
Spring Data, an NFJS Virtual Workshop