This is great and really useful to me! I am also, like others here, in the process of writing my first "book":
https://redis.pjam.me/. Mainly inspired by
https://shop.jcoglan.com/building-git/, rebuilding Redis, instead of git, in Ruby.
> For my first few sections I wrote the code as I wrote the sections, but then Lak made the suggestion that it would probably be easier to write the code first and then write the chapter
I can echo this a thousand times, I've written the last three chapters this way and this has made a huge difference, wish I had known that earlier!
I will also add that it really made me learn so much because even though I thought I knew quite a bit about Ruby (I knew early on that I didn't know much about Redis). So many times I found myself trying to explain something and realizing that I didn't actually know how it worked and ended up spending hours (days?) researching the inner workings of said thing
PS: Using quotes around book mostly because that's the imposter syndrome kicking in, I was calling it "a series of blog post" for a while, to kinda downplay it