Tales from the jar side: Welcome newcomers, Connecting ChatGPT to Java, Groovy birthday, and the usual silly toots and skeets
I accidentally glued myself to a copy of my biography. My wife doesn't believe me, but that's my story and I'm sticking to it. (rimshot)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of August 20 - 27, 2023. This week I taught a Reactive Spring course on the O’Reilly Learning Platform, and a Spring Data JPA course as an NFJS Virtual Workshop.
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.
Welcome JVM Weekly Subscribers
Last week I mentioned the excellent newsletter JVM Weekly. Here’s a link to the latest issue:
Written by Artur Skowronski, it covers the under-the-hood details of the Java language and virtual machine, getting into features way beyond what I know. In the last issue (linked above), he was kind enough to recommend Tales from the jar side to his readers, which resulted in a flood (by my standards) of new subscribers here.
I want to welcome you all! Thanks for joining. That means that Artur and I are now sharing a handful of subs, reminding me of the Gamesters of Triskelion:
I don’t know; 300 quatloos doesn’t feel like enough. I’ll immediately raise the bid to 500 quatloos and see what happens.
Whoa, that escalated quickly. I’m sure it won’t come to that. At least I’m pretty sure.
Growing up, my sister (also a Trek fan) and I used to bid quatloos for practically everything (“One thousand quatloos for the last corn muffin!”), at least until Babylon 5 came along and we switched to credits. I’m sure one of us owes the other literally millions of FCUs (Fictional Currency Units) at this point.
Of course, since JVM Weekly said nice things about my newsletter, I felt obligated to read this week’s issue. I can honestly say everything he included was new to me. I’m glad to know that deep Java work is going on, and I’m equally glad I don’t have to do that stuff. Thanks to Artur, I’ll be aware of important developments in that area without having to fight the JVM equivalents of any Thralls.
(The most surprising thing about this entire section is that the spell checker inside Substack’s editor somehow had no problems with the word quatloos. Go figure. I don’t know what that means, but it means something.)
Connecting to ChatGPT from Java
Speaking of Java, this week I published another video on my series on how to connect to AI tools from Java. The title is AI Projects in Java: Talk to ChatGPT:
The ideas are very simple:
ChatGPT is just another RESTful web service. That means go through the Open AI API by registering for an authentication key and adding that to the header of each request.
Use a Java networking client to connect to the service. In my examples I used the
HttpClient
that was added to Java in version 11.Use a JSON parser to convert between JSON objects and Java records. Records are perfect for that, and they were finalized in Java 17. I used Google’s Gson to do the parsing and generation.
The rest is just exchanging GET and POST requests and parsing the results, then refactoring the code to be more scalable and testable.
The plan next is to show how I used this system to generate a multiple-choice quiz of Java topics by sending them to ChatGPT using a parallel stream and storing the results in text files that I could merge later. Maybe after that I’ll port it all to a Spring Boot app so I can use the RestTemplate
or WebClient
and the built-in Jackson JSON parser directly.
Eventually I’ll try to integrate at the code level, assuming a Java API for the AI tools exist. JVM Weekly suggested a couple, which I’m looking into, but that might take a while. In the meantime, hey, every language can parse strings, and that’s all JSON objects are anyway, right?
Incidentally, the thumbnail was designed using Canva, but I created the robot image using Midjourney. The prompt was simply, a robot running as fast as it can. Then I uploaded the image to Canva and used its Background Remover to, well, remove the background, and added it to the thumbnail. That worked really well.
I also used the AI Assistant inside IntelliJ IDEA to (1) suggest Java records from the JSON structure, (2) refactor the code, and (3) write commit messages for me when I added the changes to my GitHub repository. The GitHub repo online doesn’t exactly match what’s in the video, mostly because it has several more examples that I’m going to cover later, but feel free to dig in if you’re interested.
Groovy Birthday
Saw this on Mastodon:
The registration link is here. I’m totally going, though I expect some rather pointed questions about why I haven’t done a Groovy Podcast in far too long. Oh well. Best to take my lumps and enjoy what is, by far, the best developer community I’ve ever been a part of, and the most fun language I’ve ever had the privilege to use.
My IT career started in Java, back in version 1.0.6, and I’ve been a fan ever since. But my first love was Groovy. Everyone in the community was so kind and helpful, and the language cut the amount of code I had to write in half. My first book was written about Groovy / Java integration. My first keynote was at a Groovy conference (GR8Conf EU, in Copenhagen, in 2016).
I’m still sad that Groovy’s moment has passed. It’s not going away, of course, and as an active Apache project, the first alpha version of Groovy 5 was just released. But sadly, if it was going to achieve widespread adoption (and for a brief moment, it looked like it might), it would have happened by now.
That’s part of the reason I have trouble doing new Groovy Podcasts any more. The pace of change slowed, mostly due to lack of company funding, but it’s hard to see so many projects I loved basically stop. These days if I ever get contacted about Groovy training, it’s often for maintaining old code or porting it to a different language, and that too makes me sad.
Maybe it’ll have a revival someday. Grails and Micronaut are still active, and the Spock framework continues to be a great testing tool. I enjoyed Geb even if I never quite got the hang of it, and Gradle has been a big part of my life for years, even though they like to pretend they didn’t come from Groovy. Most importantly by far, I wouldn’t trade the honor of being friends with people like Paul King, Graeme Rocher, Guillaume Laforge, Andres Almiray, Cedric Champeau, Dave and Zach Klein, Mr. Haki, Sergio del Amo, Iván López, Puneet Behl, Tim Yates, and so many others for anything.
So I’m actually looking forward to the party tomorrow morning, even if I expect it to be bittersweet. If you attend, please say hi. :)
Toots and Skeets
More Wisdom from Tom Gauld
I usually tell people that the economics of technical books can be summed up this way: If you buy one of my books, I can buy a cup of coffee, but not at StarBucks.
That estimate is about right for all six of my books: Making Java Groovy, Gradle Recipes for Android, Kotlin Cookbook, Modern Java Recipes, and Mockito Made Clear, and yeah, this did provide a weak excuse for listing my books here.
Boston Baseball
This is SO true, and I’m still mad about it. Every time Mookie Betts has another great day for the Dodgers (and that’s pretty much every day), I get mad all over again. Let’s move on.
The Indictments
Other captions I saw:
But they were all of them deceived, for another indictment was filed….
Speak, fiend, and enter. (The password is covfefe)
One crime to rule them all
The Injustice League
“Till the one day when the kraken met this fellow
And they knew that they barely had a hunch,
But they'd meet at Four Seasons landscaping,
That's the way they all became the Rudy Bunch.”
(Ed: Might work better as The Shady Bunch. YMMV.)
Self-reporting height and weight
In case you missed it, that’s how Trump reported his height and weight at the arraignment, with “strawberry blond” hair no less. Hey, if he’s all that, then so am I.
My New Zoom Background
Not sure I’ll be brave enough to use that on my next call, but I am seriously tempted.
Didn’t See That Coming
That is a seriously dated joke, but, then again, so am I.
And they lived happily ever after
But was it AI assisted? I thought they all had to use AI these days.
Xena vs Herc
Amen to that, especially if you take the actors into account.
I’m afraid I’m missing out
I’m afraid (rimshot) we’re all out of FOMO around here.
Evidence suggests
You know, I’m pretty sure.
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:
Reactive Spring, on the O’Reilly Learning Platform
Spring Data, an NFJS Virtual Workshop
This week:
No classes, but I’m going to the Groovy birthday party, and I have a couple projects to finish. I’m also preparing for my course I’m teaching at Trinity College in Hartford, which starts right after Labor Day.