Tales from the jar side: NFJS talks in St. Louis, Stable Diffusion images, UConn basketball, I missed the earthquake, and the usual silly tweets and toots
I was walking in the jungle and saw a lizard on its hind legs telling jokes. I said, "That lizard is really funny." "No," a local replied, "that's not a lizard. It's a stand-up chameleon." (rimshot)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of April 1 - 7, 2024. This week I taught my Managing Your Manager course as an NFJS virtual workshop, and my regular Large-Scale and Open Source Computing course at Trinity College in Hartford, CT. I also gave several new talks at the No Fluff, Just Stuff event in St. Louis, MO.
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 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.
NFJS Gateway Software Symposium
On the NFJS tour, our weekend events are either two days or three. The three-day events are really two and a half, because they start after lunch on Friday. Still, those are arguably easier, because we only have four talks each day on those events; two before lunch and two after.
The two day events are much tougher, for me at least, both physically and mentally. We cram five talks in a single day, and while a couple have 30 minute breaks in between, some are only 15 minutes. If you’re speaking all day long, as I was in St. Louis this week, that’s tough.
Of course, there is so much adrenaline that comes from both the topic and the crowd. I forget how tired I am once I’m talking about interesting things. Questions from the audience also help.
In St. Louis, my Friday schedule looked like this, though the names of the talks have been slightly modified to be a bit more descriptive:
Calling AI from Java (with an emphasis on how the different tools provide REST APIs)
The LangChain4j framework
Practical AI tools for Java developers
Practical AI tools for Java developers (twice? huh? yeah)
Modern Java 21+
In other words, three of those talks basically covered a lot of the same ground. I had a small amount of duplication, when I wanted to cover a similar topic and couldn’t assume the attendees had been to both, but they were mostly independent. Fortunately, I’ve been spending a LOT of time on AI/Java issues, and had plenty to say. I covered generating audio from text, creating images, chatting back and forth in a conversation (that’s about adding the previous responses to the next question, which is a form of memory for AIs), Retrieval Augmented Generation, custom GPTs, and lots more. I even did a brief section on Spring AI and how it contrasted to LangChain4j. By that I mean they both handle many of the same issues, but sometimes they handle them differently.
My demos involved ChatGPT (of course), Claude, Mistral, and Gemini, as well as DALL-E 3 and the Whisper model. Most of the time I used the Spring framework, but for several examples it was just raw Java plus the Gson parser.
I have to admit, though, that I was very happy to get to the last talk, because at least that one wasn’t completely new. I’ve been giving courses on the new features up to Java 21 for a while now. In the end it was such a relief to get to a topic where I was already comfortable that I wound up going long because I thought we were supposed to end at 6:30pm but it was actually supposed to be 6:15. Sigh. At least nobody got up and walked out, so that was appreciated.
There’s an old saying that you never want to be a doctor’s first patient or their last one. The first NFJS event of the season is always tough because of all the new talks, and you don’t have a feel for the timing yet or what questions you’re likely to hear. By the last event of the year you know exactly what to say and what you’re going to get back, and you’re even starting to get a little bored. I guess that means ideally you want to be somewhere in the middle. Regardless, St. Louis was first, but it went well in the end.
Or maybe I should just say that, “in the hands of a lesser presenter, that might have been a problem,” and move on. :)
Quick RAG follow-up
Last week I included a rant on Retrieval Augmented Generation (RAG). I included a demo where I added the complete text to my Help Your Boss Help You book to the context window of Gemini 1.5 and asked questions about it. My point was that it all fit comfortably into the request and I didn’t need the complexity of RAG.
I got some (mild) pushback about it. Two separate people made the excellent point that my approach was an expensive way to solve the problem, since all those 80K tokens cost money.
That’s true. I decided to find out how much, but when I went to my Gemini console, I couldn’t find a cost anywhere. I eventually had to ask on the Discord server (where they do support, such as it is). There I discovered that, at the moment, Gemini 1.5 is still in beta and therefore still free. In other words, my experiment cost me nothing at all.
Next week is Google Cloud Next, where they’ll probably announce the pricing model. I received an email saying the new pricing will take effect starting May 1.
For the record, GPT-4-turbo costs $10 per 1 million input tokens. That means if I stuff the full 80K tokens from my book into the input, that will cost 80 cents. Maybe I’ll try that this week and see what happens.
Really Bad Dad Joke
Friday evening several of the speakers all went to an Indian restaurant for dinner. While we were around the table, one of the items we had was this flatbread (or one like it):
I pointed to it and said, “This restaurant is very secretive about their bread recipes. In order to get this, I had to sign a naan-disclosure agreement.”
Everybody groaned, which was rather gratifying. What they didn’t know is that I’d been saving that gag for months, and I deliberately ordered naan for the table just so I could tell it. 😆
Stable Image Core
One of the demos I did not get to was image generation with Stable Diffusion. Stable Diffusion is an open source tool, which you can download and tune if you want. I discovered pretty early on when investigating AI tools that running image generators locally wasn’t worth it, at least not for me. They’re huge, complicated, and slow, and they change all the time. Working with them is a highly specialized skill, and I decided that wasn’t going to be my specialty.
The company behind Stable Diffusion, Stability AI, also offers a REST web service that works the same way all the others do. Back when their new version came out, which they called SDXL 1.0, I dug into their API and generated a few images with it.
It turns out that about a week ago (Mar 24, to be precise), they redid their entire programming model. Instead of doing things the traditional way, which means providing an endpoint for POST requests and expecting a JSON object in the body, their Stable Image Core facility uses multipart form data.
That’s new, or at least new to me. I mean, regular HTML forms have been producing that for decades, but I don’t generally access those programmatically. The strangest part of all is this section from the documentation, which says:
In other words, you must specify a content-type, and it must be multipart/form-data, but you’re not supposed to specify it yourself. Wait, what? How am I supposed to handle that?
Eventually, with some help from GPT-4, I was able to come up with this:
See that weird “boundary” element, which is set to “myboundary” and distributed throughout the request? That’s what you have to do if you plan on using the standard HttpClient that comes with Java.
Ugh. As it turns out, however, there are plenty of other HTTP clients out there. One of them is the Apache HttpComponents project. That class is designed to handle multipart forms, so the code becomes:
To me, that looks a lot cleaner and simpler. The hard part after that is figuring out how to extract the returned byte array and save it to a file.
To see it in action, here is the response to my prompt, “Cats playing gin rummy” (since “Dogs playing poker” is so overdone):
There is some weirdness going on with the cards, but I’m just as likely to blame the cats for that as the image generator. I’m putting that in the win column.
UConn Basketball
This has been a weird year for the University of Connecticut basketball teams. Usually the women are a juggernaut and the men are happy to make the NCAA tournament and hope to do well. This year it’s the opposite. The men’s team charged through the tournament last year and are the defending national champions, and this year they haven’t missed a beat. One the plane home last night, they had TVs in the seats, so I was able to watch the men have their toughest game of the tournament and win by only 14, advancing to the title game Monday night.
The women, on the other hand, have been devastated by injuries and never seemed to quite get it together. I mentioned in a newsletter a few weeks ago that my wife and I went to one of their games earlier in the season, and I can assure you they did not look like a Final Four team at all, though they did win that game.
Once in the tournament this year, however, they did great. They advanced to the Final Four somehow, and Friday night they played Iowa right to the end. They had a chance for a game winning shot, but were called for a questionable offensive foul with time running out and turned the ball over.
Was it a foul? Who knows? I guess, since the officials called it, it was a foul by definition, but yikes that was a tough way to lose. To be honest, though, they did wonderfully even to get that far.
A few minutes ago Iowa lost the finals game against South Carolina, who were undefeated all season and showed exactly why. Still, that was fun. If the men lose tomorrow night, however, I’m probably going to skip the Devnexus conference the rest of the week and stay in bed.
There was an earthquake and I missed it
If you were anywhere near the Northeast US on Friday, you heard about our earthquake, which registered 4.8 on the Richter scale. I know that’s not enough for Californians to even notice, but that was a big deal to us.
Or, I should say, to them. I wasn’t there. I was in St. Louis giving all those talks. My wife told me later how everything in the house shook and she had to check around to make sure nothing was broken, and wasn’t even sure what had happened until afterwards, but I missed the whole thing. Only later did I find out that the epicenter was somewhere near one of Trump’s golf courses in New Jersey, and he recently compared the criticism he’s been experiencing to the suffering of Jesus, so if you’re looking for signs from the heavens, there you go.
We’re a few hundred miles away from the path of totality for tomorrow’s solar eclipse, too, so if I talk about Eclipse it’ll probably be about the development environment and foundation.
The Candidates Tournaments
We’re starting to run long again, so I’ll probably save this for next week. Just be aware that the Candidates Tournaments for both the men’s challenger for the World Chess Championship and the corresponding women’s challenger are going on in Toronto this month. The one notable item I’ll mention is that we have a brother and sister combination involved, with Praggnanadhaa among the men and Vaishali in the women’s tournament, and both won their games in Round 3.
I’ll definitely talk about this after my week in India for GIDS at the end of the month, where no doubt many people will be following both tournaments.
Tweets and Toots
Where wolf? Where castle?
I’m assuming that if the animal is not in the dark, it’s a wolf, and if it is, it’s a human. The part that needs more data is how much moonshine (lol) does it take to transition from one to the other?
Are you joining us, Addams kids?
Wednesday would be all in.
High Speed Rail Isn’t
I like to tell young developers that when David Heinemeier Hansson created Ruby on Rails, he was thinking of high-speed European trains. No American would ever be tempted to create Java on Amtrak. Shudder.
Step Right Up
True, but only once.
Wait, were those connected?
Is that good?
I’m sensing a theme here.
What could go wrong?
That’s why I pronounce JSON data like “Jason” and not “J-son”. I like imaging a guy with a machete and a hockey mask while coding.
Now suffer!
Where’s my kiss?
Do the math
That’s just science.
Trans Easter
Trans Day of Visibility is every March 31, and this year it coincided with Easter. I think this image said it perfectly. :)
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:
Managing Your Manager, on the O’Reilly Learning Platform (APAC time zones)
Upgrade to Modern Java, an NFJS Virtual Workshop
Trinity College (Hartford) class on Large Scale and Open Source Software.
This week:
Two talks at Devnexus in Atlanta, GA