Tales from the jar side: The end of my AI book, Data-oriented programming in Java, Dad weapons, and the usual silly tweets and toots
Bugs Bunny won't accept files through Google Drive. He'll only accept a WhatsApp doc. (rimshot)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of July 21 - 28, 2024. This week I taught my Managing Your Manager course and my Reactive Spring course on the O’Reilly Learning Platform.
Regular readers of, listeners to, and 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 form:
Thanks for reading Tales from the jar side! Subscribe for free to receive new posts.
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.
I ain’t got it
The Mel Brooks parody of Alfred Hitchcock movies High Anxiety is far from his best, but it does its moments. This one occurred to me this week:
In case you don’t want to watch the video, the driver, Brophy, played by Ron Carey, tries repeatedly to pick up a trunk. He says, “I got it, I got it, I got it, I ain’t got it,” multiple times before failing. That’s only the first time it happens in the movie, but it’s a running gag.
In last week’s newsletter, I talked about the difficulties associated with the book I was working on, tentatively entitled Adding AI to Java. This was supposed to be a big writing week for me on the book, since I didn’t have any training classes and expected to make a lot of progress. My editor and I planned to meet on Friday morning to discuss the situation.
Wait a second. It just occurred to me to figure out how old Dr. Thorndyke’s (Mel Brooks) mentor, Professor Lillolman, was in the movie. According to the IMDB page, he was played by Howard Morris, who was born in September of 1919, and this movie came out 1977. That means he was only 58 at the time. In other words, and I cannot stress the Hitchcockian nature of this conclusion strongly enough: I’m already older than Professor Little Old Man.
Yikes. I’m not sure what to do with that information, other than quiz my students as he did:
Dr. Lillolman: And the most important thing?
Dr. Thorndyke: Never take a personal check!
I can’t believe they didn’t include that part on the IMDB quotes page for the movie.
Let’s get back to my story.
When I first proposed my book, the basic idea was that all the available AI tools were effectively REST-based web services. All I had to do, as a Java developer, was map those APIs to Java, and I could integrate them into Java applications. Even better, the most recent versions of Java added cool features like records, sealed interfaces, and pattern matching for switch, making them great examples of a new paradigm known as Data Oriented Programming. I intended my book to show developers how to add AI services to Java systems using this new approach.
At the time I proposed the book, there were two frameworks that planned to do something similar, in the sense of making it easy to incorporate AI tools into Java. (They apparently weren’t interested in the whole data-oriented programming idea, or not enough to use the versions of Java necessary to take advantage of them.) Those frameworks were LangChain4j and Spring AI. Neither was anywhere near version 1.0, however, implying that they might change substantially. My original plan in my book was to leave the discussion of those frameworks until a late chapter, and then use them to do a RAG example (retrieval augmented generation), since that’s too awkward and tedious to do “by hand,” which is what I called the REST approach I advocated.
As the year went on, however, the frameworks got better and better, especially at doing the simple things. For example, to do a basic chat example with the REST API for Mistral (the French AI tool whose API is almost identical to the OpenAI API), I have to map the input and output records:
Then I have to define an interface (assuming I’m using Spring):
Configure the necessary beans:
and test it:
That’s leaving out the fact I usually inject the interface into a service class to simplify the system for users.
Here’s a similar example using LangChain4j, where I’ll just go to the test, because it’s that easy:
There are ways to configure the builder to add lots of options, but I’m basically done.
Seriously, that’s the complicated example, involving creating messages and parsing the responses. With LangChain4j, I can also add memory, and tool support, and what they call “AI services,” and the list goes on and on.
In other words, it’s become difficult to argue in favor of the REST API when the frameworks reduce my examples down to 10 lines or less and then go way beyond them.
It’s still worthwhile to know the REST approach, for a few reasons:
You should always understand one level below whatever abstraction you’re using. That way you know what the framework is trying to do, and how to handle it when it fails. Just because you know Hibernate doesn’t mean you don’t have to learn SQL, for example.
Both frameworks have version numbers less than 1.0. That means they are subject to significant changes with no warning (I’m looking at you, Spring AI).
When new capabilities come out, you don’t have to wait for the framework developers to incorporate them. The developers may have other priorities, but you can proceed right away.
The frameworks aren’t using all those cool new Java features. Heck, LangChain4j is compatible with Java 8, for crying out loud, so no records, no text blocks, not even collection factory methods. With the REST approach, you can use the latest Java version and experiment with data-oriented programming immediately and see how it fits your tastes and interests.
The problem, though, is it meant that each chapter of my book was turning into:
Here are five lines of code to show how LangChain4j handles the problem (chat, image generation, vision, audio models, whatever).
Here is a similar five lines of code showing how Spring AI solves the same problem.
Here’s thirty to fifty lines of code showing how to use the REST API directly, which is fascinating and instructive, but hard to justify when the frameworks are so simple and easy.
Also, what about Semantic Kernel from Microsoft? Do I want to add sections for it as well, though it’s mostly just a port of their C# API to Java? If not, how can I justify leaving it out?
The result may be a valuable book, but it’s hardly the book I intended to write. If I wanted to write that book, I would probably have to start over anyway. Just tacking on the LangChain4j and Spring AI sections to each chapter throws off the balance so badly I’d have to explain every time why I didn’t just stick with the frameworks, and I didn’t want to fight that battle.
As you can probably tell, in the end my editor and I decided now was not the time for the book I’d planned. Maybe later, after the frameworks truly stabilize, I can talk about what’s going on under the hood, but my current book had way too many questions around it to be worth all the time and resulting arguments.
So yeah, I ain’t got it, at least not any more. I’m not worried about all the time I’ve already spent. I learned a ton, and it’s been really productive. I’ve gotten multiple training classes and NFJS talks out of it, not to mention my upcoming course on AI Integration at Trinity.
Let me stress, in case anyone is wondering, that the publisher was fine with all this. Everyone was kind and understanding, and we may work together again in the future. But I think my timing was right, too. If we had gone to beta and sold some books first and then tried to cancel, that would have been awkward. Better to pull the plug now.
I’ll also make some videos out of what I’ve learned. Speaking of which…
Data Oriented Programming in Java
My latest video doesn’t do anything with AI, but it does contain a couple of simple examples of data oriented programming in Java. It shows how you can combine records, sealed interfaces, and pattern matching for switch to make a nice example application. I did one that was trivial, and one that accessed a REST-based web service.
The video has already done better than I expected, so apparently there are developers out there interested in this topic. That’s good, because it gives me a reason to do more examples following the same pattern.
Dad Humor
My son moved out about a month ago, and I’m pretty sure it’s for real this time. He bought furniture and everything. He may never remove all his stuff from his room here, but that’s more an issue for my wife than from me.
I recently got a text from him. It showed a picture of his TV screen trying to access a streaming service using my account, and asking him to enter a code into the web site directly. In case you haven’t been through this process, he wanted me to go to the streaming site, log in, and add his TV as a supported device.
I briefly considered refusing, but I have no interest in helping some streaming business preserve their annoying business model. Instead, I decided it would be funnier to approve it and add serious Parental Controls to his account.
Okay, I didn’t actually do that (the parental controls part — I added his device), but I texted him that I might limit him in the future as a vague, unspecified threat in case I need to get him to do something around the house.
I didn’t realize until my son got older that so-called Dad Jokes (like the ones I put in my newsletter subtitles) are one of the few socially-acceptable weapons I have in my arsenal to get back at the boy for all the pain he has caused me over the years. Now, it appears, I have another one. :)
Tweets and Toots
The Cake Is A Lie
That works.
Testing Positive
And I thought my Dad Jokes were bad. Of course, I get most of them from that particular Twitter account, so it’s probably not too surprising.
Also, yes, I’ve decided to call that site Twitter, mostly because that seems to really annoy Elon.
Cat Lady
I understand that Trump’s disastrous interview with the National Association of Black Journalists was a lot like him saying to JD Vance, “You think you offended people? Hold my beer,” but this stuff isn’t going away. In order for Vance to be dropped from the ticket, Trump has to admit he made a mistake, and that’s never happening, so we’ll see how this plays out over the next couple of months.
Speaking of Vance,
I can see how that might be a problem.
DEI Hires
Those three are not actually DEI hires, they’re nepo-babies, but sure, I’ll go with it.
Stranded? Of course not
Okay, that’s funny. The only problem is that prisoner exchanges can take months to arrange, and you know how it is with guests who won’t leave.
No one is above the law
Seems only fair.
Low-information voter
My struggle to become a low-information voter continues, but at least the past couple of weeks haven’t been as miserable as earlier in the year.
Finally, a cat joke
Have a great week, everybody! And don’t neglect the symptoms of High Anxiety. It afflicts one in seven!
Last week:
Published a new technical video, which was a nice change.
This week:
Making New Java Features Work For You, on the O’Reilly Learning Platform.
My wife is having knee-replacement surgery this week, so pray for me. Or her, I suppose, but my life is going to be seriously affected until she recovers. That should be really quick, right?
Have you been granted immunity for your jokes? ;-)