Last May I wrote about a new book I’m working on, tentatively titled “Practical Math for Programmers” (working subtitle, “A Tour of Math in Production”, h/t to everyone who contributed suggestions). I thought now would be a good time to share some updates.
In May I had written 9 chapters (each 3-5 pages with a code sample). As of today I have written 16, with two more in an in-progress state. It’s been slow going in part because I haven’t been prioritizing book writing (until the start of 2022), in part because I had other life changes going on (bought a house, moved to Portland, OR, helped my parents move/buy a house, renovations, just needing to relax, etc.), and in part because I’ve been tackling more challenging and unfamiliar topics that require more research.
On the positive side, this year I joined an amazing writer’s group for technical nonfiction, and it’s incentivized me to write at least one new chapter every month so I can send it to these peers for feedback. I’ve also made an agreement with my wife to set aside at least 4 hours each week for undisturbed writing, which has been fantastic, but not enough to make the sort of rapid progress as I’d like. I.e., at this rate, 1-2 chapters per month, it’ll take me 2-4 more years to finish.
Another interesting aspect is that I’ve started to incorporate proper interviews into my writing routine. For example, I had a lovely interview with Josh Menke on TrueSkill and Bayesian methods for skill ranking in online games (cf. TrueSkill2). It’s been great to talk to people working in the trenches, so to speak, who can really elucidate the advantages and limitations of particular techniques. And most importantly, validate that yes, these techniques are used in prod and we like it that way.
I really enjoy the story-telling aspect of it. While my last book focused on math culture and lore (both as I understood it and pulling from writing of famous mathematicians), it wasn’t the kind of thing that an average programmer would appreciate if they aren’t already into math. And when I shared a few sample chapters of Practical Math with a non-mathy friend, she told me she was much more drawn in to the chapters that had historical context and framed problems more holistically, rather than just saying, “here’s how to determine if a point is in a polygon using winding numbers!” For the German Tank Problem, for example, there’s this exciting story about uncertainty in war and naive overestimates and how the solution solved this critical, real problem in a creative, but simple, way.
While I did indeed write about winding numbers, and I intend to keep that chapter in the book, I really have no story behind it, beyond that it’s measurably simpler and better than alternatives. (If you have practical experience with this in a real game, I’d love to hear about it!) Nor do I have any references to which games/game engines use it and what practitioners think about it.
Another helpful part of writing has been live-tweeting my research, interesting findings, and random struggles. It only takes a few seconds to say what’s on my mind, but then Twitter friends forward me to interesting people they know with extra context, or code repositories doing similar things. It’s helped discover people to interview and generally made the process of writing feel less lonely. I’ll have a large “thanks” section for everyone who helped on specific topics.
Another thing I haven’t really gotten started on yet is the essays that will fall between major sections of the book. Some of these major sections include “Dealing with Uncertainty,” “Efficiency,” “Search,” and between I’d like to include essays on ethics, analogies, and broader themes that occur throughout multiple tips (like how to trade off the complexity of a new math thing vs long-term maintenance).
Perhaps needless to say, I’ll be de-prioritizing blog writing this year as I focus on book writing. But as I go, I’m finding all kinds of interesting things that are too long to fit in the book, but would be awesome for a blog post or blog series. For example, in my research on TrueSkill and Expectation Propagation, I decided it would be fun to try to implement my own EP algorithm for a generic factor graph, with some limited support for special distributions, in the style of Infer.NET. To my knowledge, no other probabilistic programming systems support EP, so this might end up being useful for wider adoption.
I also keep coming up with test articles I want to run on the blog for “A Mathematician’s Introduction to Programming,” similar to the Riemann Hypothesis series I never quite finished. But alas, that may have to wait.