Tales from the jar side: Adventures in AI with Java text blocks, Elon musks it up again, YouTube activities, and the usual tweets and toots
I told my son not to listen to losers and now he won't talk to me. (rimshot)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of June 25 - July 2, 2023. This week I taught my Java Testing Part 1: JUnit course and my Java Testing Part 2: Mockito courses as NFJS Virtual Workshops. On the YouTube channel I published the newsletter video, one long-form video, and a single Short. I also held another Live Stream, with Jonathan Johnson More about all of those those below. On Friday I began the long journey to Chania, Crete for the JCrete Unconference, which starts tomorrow, so if this issue of the newsletter is all over the place, I’ll blame travel fatigue.
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.
Adventures in AI
JetBrains, the maker of the IntelliJ IDEA development environment (my IDE of choice), announced that in their latest EAP (Early Access Program) version, they now include an AI Assistant. For the record, it feels like ChatGPT with the serial numbers filed off.
Parts of it look promising. I like that it can generate commit messages for you for when you check code into source code control. That’s always kind of annoying, and it adds more detail than I normally would. It also generates Javadoc documentation for your methods, but I rarely do that so I don’t much care. It will also suggest names for your methods based on their contest, which I guess could be useful.
My direct experience this week wasn’t so promising. My GitHub repository for my Mockito Made Clear book is based on Java 11, and I was reluctant to use anything beyond Java 8. In my training class this week, however, I was using Java 17, which means I had a lot more features available. One features, in particular, is the ability to use text blocks as a CSV source, and I thought that was worth a try during class.
A text block in Java is a multi-line string, and it was added to Java in version 15. In a JUnit test, a CSV source stands for “comma-separated values,” and is described in this section of the User Manual.
The sample in the manual is:
The idea is that in a parameterized test, each row of the multi-line string will be used as arguments for the test. My example looked like this:
I tried running this, but was surprised when only one of the two lines was used. I tried to fix it during class, but started to get bogged down, so I told the students I would figure it out afterwards.
(I did, of course, make the necessary joke about using a @WalgreensSource
instead of a @CvsSource
(rimshot), which got more chuckles than it deserved.)
If you have some experience with Java, you might have noticed that I left out the name of the parameter in the @CsvSource
annotation. That default to value
, which compiles just fine, but still didn’t work.
After class, I decided to ask the AI assistant first and see what it said. Here’s a brief summary of that conversation.
First it said that my problem was that I provided a String, but the argument to the test was a LocalDate, and that’s causing an issue. I told it that was fine, and it is. It also converted my text block into an array of strings, which missed the entire point.
After I told it that, it admitted there’s nothing wrong with supplying a string, and went back to a text block. It suggested I set a property called
lineSeparator
to make sure it understood where to parse my text block. It claimed this was a known problem with JUnit (!) and what it suggested was a reasonable work-around.I pointed out that there is no property called
lineSeparator
in@CsvSource
. It apologized again, and suggested I embed an actual newline character“\n”
inside the string, to indicate where the line break was supposed to be. In the process, it went back to an array again.It apologized one more time and suggested going to a
@MethodSource
where the method parsed the string for me.
At that point, I realized it didn’t have a clue, so I gave up on it. That’s when I looked at the sample from the manual a bit more closely, and finally realized I needed to set a property called textBlock
instead of value
to make it all work:
Yup, that does the trick. RTFM, and all that, though I did read the effing manual. I just didn’t pay close enough attention to the details the first time.
So much for AI assistants putting us out of business.
The other AI issue I ran into this week came from the question bank I described creating in last week’s newsletter. Those questions were created using Google’s Bard instead of ChatGPT, mostly because I couldn’t get GPT to read files on my disk or generate Google Docs for me, while Bard was only too happy to do so.
This week I started reading a lot of those generated questions, and ugh, a lot of them were not good. Not terrible, exactly, but a lot of bad assumptions, or misinterpretations of what I wanted, or duplicates of earlier ones. It’s taking a lot longer than I anticipated to clean them up. Still not as long as it would have taken to write all those questions myself, but a lot more post-processing than I had in mind. I can’t complain too much about that, though. It’s probably karma biting me for trying to avoid work.
Elon is Not Only Stupid, He Lies, Too
Speaking of karma, I liked this cartoon I found online:
Everything was going along fine in Twitter world (for very flexible meanings of the word fine), when some time on Saturday Elon decided to change things. I was on a plane flying across the Atlantic when I first ran into problems, which was an error message that said “Updates unavailable; try again later.”
After a few tries, I realized something was wrong with the site. A lot of other people realized the same thing. It turns out Elon, in his infinite stupidity, decided to make two changes:
You have to be logged in to see any tweets at all, even from the main web page. Since that page itself sends requests for tweets at the rate of about 10 per second, that resulted in a self-inflicted DDOS (distributed denial of service) attack on the site, killing performance. That had nothing to do with my problem, but yeah, it was dumb, and supposedly done to keep the big machine learning programs from using Twitter data to train themselves.
He also suddenly imposed rate limits on everyone. If you’re not “verified” (which has nothing to do with verification — it simply checks whether or not you’re paying Twitter the $8/month they want), you’re limited to reading only 600 tweets in a given session. That sounds like a lot until you realized practically every third tweet these days is some garbage “promoted” tweet from the only advertisers he can attract.
Both of these changes were imposed with no warnings and no explanations. One moment you were reading the feed, and the next you were blocked with an error. Eventually he posted a tweet (which hopefully you could read) saying both changes were made to fight the tweets being used to train the next generation of AI tools.
The best real explanation I saw is that Twitter uses the Amazon Web Services cloud provider and Elon is notorious for not paying his bills. They hit the end of the month / quarter / half-year at the end of June, and supposedly Twitter owes Amazon something like a billion dollars (!), so Amazon started to cut them off. The throttling was done to try to keep the site running at all while they try to transition from Amazon to Google.
I have no idea if any of that is true. The best response I saw was:
This seems plausible, because regardless of what the actual reasons are, Elon is an idiot. Several people did note that he’s doing this at the same time he’s trying to bring advertisers back to the platform, which is nuts.
The reaction among those of us hanging out on Mastodon was:
That pretty much sums it up.
The best tweets I saw in response (taken while I still have a Twitter account) were:
The “invitations to a competitor’s business” remark is about the fact that the Bluesky app is still invitation only. Bluesky is okay, I guess, though I spend less time on it than on Mastodon. On a related note, I now have two invitations I can give out in case anybody wants one, which I suppose is also a way to find out whether anyone actually reads this far into the newsletter.
I have to say that “He really musked it up this time,” is a phrase I dearly hope becomes a meme. Honestly, Twitter is still a (too) big part of my life and it’s devastating to watch its owner do everything in his power to destroy it. I really, really hate that guy at his point, and am ashamed I ever thought well of him.
YouTube Activity
Last Sunday I released a new long-form video on HTTP Interfaces in Spring based on Dan Vega’s video on the same topic. I guess that really qualifies at last week rather than this one, because I even talked about it in last week’s newsletter. Here’s the link, btw:
The video is doing reasonably well, at least by my standards, with about 150 views and 9 likes (one of which was fortunately by Dan Vega himself). Why did I include that this week? I remember when the Millenium rolled around, some people kept debating whether the new millenium started January 1, 2000 or January 1, 2001, and my opinion is that any reasonable person would have a party on both days. So yeah, I’m counting it twice.
In addition to the regular newsletter video, I also released a Short, called Using parallel streams in a test. That’s an excerpt from last week’s newsletter video, made with Descript, where I showed a test that used parallel streams in Java to download 100 posts concurrently. That one only got about 50 or so views, but since I made it mostly as another experiment in extracting shorts from long-form videos using Descript, I guess that’s okay.
I did do a live stream, however, with my friend and fellow NFJS speaker Jonathan Johnson:
He’s had an interesting life and career, and his areas of expertise complement mine. He’s way better at the operations part of IT than I am, where I spent more time on the development side. Feel free to check it out if you’re interested.
JCrete
Since I only arrived here on Sunday, I don’t have much to say about the conference yet. I’ll have a full report next week. I’ll just say that my wife and I spent Friday night in a hotel near Logan Airport in Boston, flew to London early Saturday morning, losing 5 hours along the way, then spent the night in a hotel at Heathrow Saturday night, and finally flew to Crete today.
We’re both tired already. But the conference should be fun, and she’s got all kinds of plans about places to go and things to see while I’m busy playing with technical stuff. So far temperatures are in the high 80s (Fahrenheit, of course), so it’s nice and easy here. I have a lot of work I have to get done during the conference.
This, by the way, is an “unconference,” meaning “let’s get a bunch of clever people together and talk about whatever we want,” rather than schedule a bunch of talks. I’ve never done that before and have no idea how it will go.
Tweets and Toots (or even Skeets)
I’ve already covered a lot of this in the section on Elon and Twittera above, so I’ll be brief. A “skeet” is what they call posts over on Bluesky, for some odd reason.
Shohei Ohtani rules, but…
By now you’ve probably heard about Shohei Ohtani, who is currently one of the league leaders in both home runs and pitching wins, which is simply unreal. He’s stuck on an awful team (the Angels). He’s going to be a free agent at the end of the season, so we’ll see which owner is willing to pay him anywhere near close to his worth then.
Battle of the Nerds
The best commentary about the proposed fight between Elon and Mark Zuckerberg came from Elon’s mom (and her active Twitter account), telling him to knock it off. Someone (I can’t find the tweet any more) said that the fight being canceled because Elon’s mom won’t let him would be the best possible resolution to this silliness.
The Writer’s Life
Yet another classic quote from Dorothy Parker, but they all are, really. This one popped up this week.
Chess Cheating Scandal
I talked about the Hans Niemann cheating scandal a lot several months ago in this newsletter, and Niemann’s resulting lawsuit. That’s now dismissed. So be it. We’ll see if there are any further ramifications later.
I’d read that
Great one from Tom Gauld again:
When I was in school, the saying was that if any brainstorm session didn’t bring up lasers it wasn’t really trying. Now that would probably be AI.
Today is a good day to …
As a character, he was never really like that, but it’s a pretty good gag.
Hey, Scottie wore a red shirt too
Good point, if rather devastating.
No “skeets” from Bluesky this week, partly because it’s not that active for me, and partly because I don’t see any way to find the posts I liked. The app really is primitive at this point.
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:
Java Testing Part 1: JUnit and AssertJ, an NFJS virtual workshop.
Java Testing Part 2: Mocks, Stubs, and Spies with Mockito, ditto.
This week:
JCrete, so conference stuff and no classes. Lots of work to get done though.