Spinning yarns for you and me
The verb behind the noun
When people ask you what you do, do you use a verb or a noun?
Do you say, “I write books” or “I’m an author”?
Do you say, “I help create apps” or “I’m a developer”?
Some jobs it’s easier to do than others, but if you use verbs - and some jobs require more verbs than others - you may notice a pattern that tells you something.
The exercise is similar to writing or updating a resume - something I haven’t really done in decades.
Use active words and look for patterns that help you identify the kind of job you want to have or the kind of job you’d be good at.
I might say that I’m a teacher, writer, developer, podcaster, … but underneath everything I do - I tell stories. I’m a storyteller.
Once I understood that and said it out loud, I better understood what sorts of classes I should be teaching, what kinds of books I should be writing, what kinds of apps I should be shipping, and what kind of audio stories I wanted to tell.
My Async Book
I’m writing a book about modern concurrency in Swift.
Before your eyes glaze over, I just want to say that it’s a difficult topic and it’s going to be increasingly important for the folks who write apps for your phone and laptop to understand.
There are other books out there on the topic and more on the way. These are books that provide examples - some exactly like Apple’s examples and some not - and show you how to write the code. Some take a really deep dive to make sure you understand exactly how the system works and what the hidden but important details are.
That’s not the sort of book I write.
I write books for smart people who don’t know the thing I’m writing about. I don’t tell them everything. I try to give them a feel for the thing we’re covering so they can go to the official documentation and other books when they need details of how to accomplish their specific goals in their specific context.
I’m happy to know that some people don’t need those other books after reading mine - but that’s not my goal. I hope to tell you a story about async that lets you reason about your code and make it better.
The key to asynchronous coding is that some things take a long time. For example, suppose I’m at a coffee shop with a really slow internet connection and while I’m writing this I want to do a web search to make sure a reference I’m making is correct.
I type my search into Duck Duck Go and hit the return key.
What if my entire laptop froze up and I could do nothing else until the search results appeared in my browser.
That would suck.
See, I knew you could learn this stuff. That’s essentially the problem that async solves.
There are a bunch of techniques for continuing about your business while you wait for these long-running tasks to complete.
Of course there are all sorts of issues when we try to work with time-travel.
“Issues,” my old boss Andy used to say, “I don’t have issues. I have subscriptions.”
The joke was funnier twenty years ago when he told it. We worked in a publishing house and magazines were still a thing.
Anyway, one of the issues is information that persists across a suspension point.
“What the hell are you talking about Daniel?” you ask.
While I’m searching the internet I continue to write this newsletter. When the search results come back for “Parisian Cafe Image” I have no memory of why I initiated that search.
If I’d taken a moment and jotted down a note, “Ideas for cover art”, then when the search returned I would have had a reminder in front of me.
And that’s the way persistence works across a suspension point.
These stories are why I love teaching, writing, coding, …
The stories I tell others to help them understand and remember things - they are invaluable to the future me when I’ve forgotten something.
Forty-some years ago when I first taught high school math the curriculum included the distance formula.
“That’s fine,” I told my students, “but it’s really just the Pythagorean theorem. You can memorize this if you want or you can figure out one side of the triangle from the x’s and the second side from the y’s. Use Pythagoras to calculate the third side and the square root is the distance.”
Nothing to memorize.
Forty-some years later I can recreate the distance formula. I hope that some of them could too if they took a moment to think about it.
As the weather has turned cold, I’ve been baking bread again.
You can bake bread by looking up a recipe and measuring out the amounts they give you.
You can also read a formula which involves you using percentages and so on.
I tell a story in my Bread book. It’s a story I can remember and so I can bake a whole range of different breads from memory.
The story, which I’ve told, is 1 - 2 - 3 - 4.
So Saturday night I thought I’d make bread the next day. I figured a two pound loaf would be about the right size and that’s roughly 900g.
1 - 2 - 3 - 4
Saturday night I need to make a Poolish. That’s the 2 in 1 - 2 - 3 - 4. It’s one part flour and one part water with a pinch of yeast. If 900g is ten parts then 90g is one part so I mixed 90g of flour with 90g of warm water and a pinch of yeast. I stirred and put it covered in a warm place.
Sunday morning I measured out 3 parts of warm water (270g) and 4 parts of flour (360g). What’s the 1? Well the 1 is my accent flour. What flour do I want to use to change the characteristics of my loaf? In this case I used rye but other times I use spelt, whole-wheat, or the same flour I’m using for the 4 parts.
All together that’s 6 parts flour and 4 parts water. I added 10g salt and 4g yeast and mixed the dough. This is what bakers call a 67% hydration level. It’s about the consistency of a baguette. I always measure out extra water so I added another 40g of water. But these are adjustments - in my head it’s just 1 -2 -3 - 4.
A good story is easy to tell and easy to remember.
It tastes delicious as well.
Essay from Dim Sum Thinking Newsletter 141. Read the rest of the Newsletter or subscribe