Tales from the jar side: Kotlin Cookbook in other countries, Reactive Spring, and a few random thoughts
Please feel free to buy my books and not read them. Use them for doorstops, to prop up a table, or whatever. Seriously, I don't mind. It's all good.
Welcome to Tales from the jar side, the Kousen IT newsletter, for the week of August 9 - 16, 2020. This week I taught a basic Spring and Spring Boot course on the O’Reilly Learning Platform and a Reactive Spring course for a private client.
Today in books I (mostly) can’t read
I received these in the (actual, physical, currently-under-assault) snail mail:
Yes, those are the Korean and French editions of my Kotlin Cookbook. Both books came in separate packages on the same day. Right after that, my editor at O’Reilly informed me that there is also a Chinese edition, at this web page. I went to that page and used Google Translate to convert it to English, more or less:
Two interesting parts of that site are worth further comments. First, the reviews (and there are several pages of them!) mostly talk about the discount, the quality of the manufacturing, and the translations. Several say things like, “the book is very good, brand new, I want to buy it and have a look” and similar notions. Nothing fake about that at all, right? If only I had a few hundred fake friends who could add similar one-line reviews at Amazon.
Second, and this is fascinating, there is an actual video on that page. If it was on YouTube I could upload it here, but as it is I can only point to it. (That link opens it in a separate window.) The video is 28 seconds long, zooms in and out, opens the book, lies it face down on the table (?) and shows the table of contents, all to a woman’s narration in Chinese. If you speak Chinese (I’m guessing it’s Mandarin, though honestly how would I know), I’d love to know what she is saying, though I doubt it’s anything profound or unusual.
And yes, you better believe I saved that video to my disk. I’m thinking of using it as my introduction video next time I give a talk. :)
Will I see any royalties from these three editions? Presumably? I guess? I’m not sure how I’ll know, since the royalties report I get from O’Reilly doesn’t appear to separate out where the sales come from. I think it’s unlikely the book will earn enough for me to stop working. I’ll have to check the next couple reports, however, to see.
In the meantime, I have to keep my day job. Speaking of which…
Async is hard
I taught a private class this week on reactive applications using the webflux module in the Spring framework. The term “reactive” means you are making a request and then waiting for a response, but you can do other things while you wait. I like to give the following analogy:
Say you want to order lunch at a fast food restaurant (I’d make a crack about how we used to be able to do that, long ago, kids ask your parents, but those jokes are already starting to get old). You get in line, and when you reach the cashier you put in your order and pay for it. If the restaurant were completely synchronous, like much of the web, you would stand there waiting while the kitchen prepared your lunch. You would wait in line until it was delivered, and the cashier would be idle the whole time.
Of course, we don’t do that. The cashier hands you a receipt, on which you find a number. That number is the promise that when your lunch is ready, you will be called back to pick it up. That way the cashier isn’t blocked — they can serve other customers while you wait. You’re not blocked either — you can go get your drink, or grab a table, or whatever else you want to do while the lunch is being prepared. Eventually your number is called and your lunch is delivered.
The problem is that it takes far less time to take an order than it does to prepare the lunch. If the restaurant is completely synchronous, they can add cashiers, but then you’ll just have three cashiers idle rather than one. Note also that adding cashiers doesn’t make the kitchen any faster. In fact, even if you’re asynchronous, where the cashiers are assigning numbers instead of having customers wait in line, it still takes as long to prepare your lunch as it did before. If too many people are waiting for their lunch, the restaurant can add cooks, but that’s a different problem.
The result is that “asynchronous” or “reactive” programming is about scaling rather than performance. A reactive system doesn’t speed up the kitchen. Instead, it keeps the cashiers and the customers from standing around idle.
Sounds good, right? The problem is that programming that way is hard. Different events happen at different times. You can keep working with a response even before it’s delivered, but that can be confusing. So while lots of companies say they want to do reactive coding, the reality is that unless you have those very specific scaling issues, it may not be worth the time and effort to adopt it.
My training class this week was about trying to help some moderately experienced Spring developers adopt the webflux module, which is how Spring does reactive streams. That meant learning about the reactive streams specification, how it is defined in Java, how the project reactor library implements it in terms of classes called Flux and Mono, and then how Spring uses those classes in annotated controllers or functional endpoints. Oh, and by the way, all of that uses the functional features like lambdas, method references, and streams, that were added in Java 8. To top it all off, we had two days to do it.
The class went reasonably well, I think, but that’s really up to the students and even then they may need some time for the concepts to settle. That’s a lot to learn in a short period of time. I have to admit that when I first dug into that module, I had many years of experience in Spring, Java, and even asynchronous systems, and it still took me a long time to wrap my head around all that. So in class I did what I normally do, which is to discuss the principles, give a handful of examples, and point them to other resources for more information.
I should mention that two of those resources are the Spring in Action book by Craig Walls (currently in 5th edition but he’s working on the 6th edition, so that’s the one in the link) and the new self-published Hacking with Spring Boot 2.3: Reactive Edition by Greg Turnquist.
(Please don’t tell Greg that while I bought his book, I still haven’t read much of it. I’ll get to it, Greg. I promise, but in the meantime at least you can count the sale.)
As an aside, let me tell you my policy on people buying and not reading my own books: Go for it. If you buy one of my books, I see the sale and make a tiny amount of money, the publishing company is happy, and the book looks nice on your bookshelf (electronic or otherwise). If you don’t read it, you don’t find any bugs or see anything you vehemently disagree with so strongly that you complain about it on social media. You also may feel mildly guilty enough so that if we meet, you try to be nice to me without explaining why, though you may even say you bought my book.
So it’s all good. Feel free to buy whole stacks of my books and not read them. Believe me, I don’t mind at all. Heck, you can even add one of those fake-seeming one-liner reviews to Amazon if you want. I’ll even write them for you.
(Just kidding. Please generate your own fake-sounding one-liner Amazon reviews.)
For IT books, I’m guessing that percentage has a few extra zeros in it, but I’m not trying to replace my day job anyway. Good thing, too, or I’d be in trouble.
For the record, my first book, Making Java Groovy, was published in 2013 by Manning. The most recent royalty report was for the first quarter of 2020 and was for about $35. The book has sold 4010 copies as of June 30, 2020, which I consider quite successful.
For the O’Reilly books, I only have direct access to monthly numbers, which are a month behind. The June 2020 report says that Modern Java Recipes sold 19 copies that month, and my Kotlin Cookbook sold 94. I think those are good, but I don’t have much to compare to.
Here’s another take on a similar point:
I’m glad I wrote my books, but to be honest the private training class I taught this week probably made more money than all my combined book royalties over the last five years. The moral, as always: if you plan to write a technical book to make money, the best thing you can do is go in a dark room and lie down until the feeling goes away.
Miscellaneous
Let me keep things mercifully short this week by switching to bullet points.
This news item about the new saliva test for COVID-19 out of Yale is potentially very good news. It’s apparently what the NBA is using to test asymptomatic players in the bubble, and it’s both cheap and fast. That could make a huge difference in how quickly we can emerge from the pandemic.
The Star Trek: Deep Space 9 episode Duet is one of my favorite episodes of any Trek series ever. Just a wonderful job by all concerned, and it happened in the second-to-last episode of their first season. I rewatched it this week and it was as awesome as I remembered.
Speaking of Trek, my wife and I are really enjoying the animated series Star Trek: Lower Decks. There have only been two episodes so far, but we laughed at both of them and it’s amazing how much the writers manage to pack into each one.
I also had a random thought about Trek this week:
Wouldn't the voice recognition and stored preferences on the Enterprise computer be good enough that Picard would only have to say "tea"? Heck, I bet Alexa could do that NOWThat triggered a rather interesting discussion about both Alexa and Trek technologies, which you’re welcome to follow if you’re seriously bored.
Here’s a figure I saw on Twitter this week. I can’t reference the creator because I wasn’t able to track that down, unfortunately. I’ve seen entries in the top row and first two in the bottom row many times. It’s the last one that’s new.
Finally, just one note on the chaos surrounding the upcoming U.S. elections: keep in mind that there are virtually zero undecided voters in this country, and few remaining historically have split down the middle anyway. (Honestly, can you imagine being undecided in this election? Seriously?) That means nothing done by the campaigns means anything in terms of the actual results. All that really matters is how many voters will be able to have their votes counted. If you’re going to spend any time or energy on the election, mentally, emotionally, or financially, keep that in mind.
Last week:
Spring and Spring Boot, on the O’Reilly Learning Platform
Reactive Spring, private class
This week:
Functional Java, Mon/Tues on the O’Reilly Learning Platform
Spring MVC, Thurs on the O’Reilly Learning Platform
Functional Programming in Java, Groovy, and Kotlin presentation for the Utah Java Users Group, Thursday evening. Register here if you’re interested in attending. I guarantee there will be cat pictures.