Justin du Coeur (jducoeur) wrote,
Justin du Coeur

Review: How to Bake Pi

Most of my posts tend to be either programming topics, which are mainly intended for the engineers, or more generally spread over a lot of topics. This one's a bit unusual: it's a book review, partly for the engineers and partly for everybody. This will make more sense as we go.

tl;dr: How to Bake Pi, by Eugenia Cheng, is a delightful ride through the topic of Math. I recommend it to everyone over the age of twelve, but *why* I recommend it somewhat depends on who you are.

Why Everybody Should Read This

The first half of the book explores the question What Is Math? Mind, her definition of "math" may not be the one you're familiar with. There are numbers here, but not nearly as many as you'd see in a typical math textbook, because she's trying to tease out the much more basic questions of what mathematics is, deep down, and why you should care about it. Yes, there are some equations as examples, but this is mainly talking about how to use math to understand the world more clearly.

To serve that purpose, she uses analogies. OMG, all the analogies. Seriously -- be prepared for a new metaphor on each page: she is very serious about illustrating her points using the familiar world, rather than the usual abstruse descriptions. This is a book about abstract mathematics, but it compensates by being as real and concrete as it can be.

Those analogies cover almost every imaginable topic, but the one that dominates the book is cooking, and particularly Baking. You get the strong impression that, if she hadn't become a professor of Category Theory, she'd have opened a cupcake shop. Every chapter opens with a tasty-looking recipe that illustrates that chapter's premise. Abstraction starts with Mayonnaise / Hollandaise Sauce, two recipes that are identical aside from a small tweak. By contrast, Generalization starts with Olive Oil Plum Cake -- a recipe that is almost, but not quite, completely unlike Cake, but fits in the general category of Cake-Like Foods.

Most importantly, the book is *fun*. It's about why Math is useful, yes, but even more it's about why Math is *neat*. There's a sense of exploration that you see more in eight-year-olds than average professors, and she conveys her enthusiasm well.

Why Programmers Should Particularly Read This

For the past three years, as I've been digging deeper into Scala and the cutting edge of programming, I've heard over and over again that Category Theory was ever-more-important, but nothing explaining clearly what the heck Category Theory *is*, or why it's relevant. Unfortunately, the folks who understand it well tend to just burble on in jargon, without ever really explaining the basics. (The worst example of this is Scalaz, one of the most important and annoying libraries in the Scala ecosystem. It's full of deep, powerful, general data structures, with scarcely a shred of documentation. What do you *mean* you don't know what a monoid is?) Despite getting to the point of writing my own Monads for Querki, I really felt like I was missing the fundamental underlying clue of what Category Theory is.

The second half of this book is all about Category Theory. Professor Cheng is, first and foremost, a researcher and teacher of Category Theory, and the first half of the book -- all that What is Math? -- is leading to the second half, talking about Category Theory, which is essentially the Math of Math. She explains what it is, *why* it exists, how it ticks, and gives scads of examples. She only covers a few of the major concepts, such as Groups and Monoids, but most importantly she gets the *idea* of Category Theory across. Basically, this is the Rosetta Stone of this branch of math: the key that lets you start understanding the rest of it.

So why is this important for programmers? She doesn't talk about programming at all, mind, so this is my interpretation, but I finally get it: Category Theory is the science of Refactoring Reality. That is, just as Refactoring is the all-important programmer's art of finding the right abstractions, the ones that clarify the parts of the problem and can be reused, this is all about refactoring *math* itself. She gets into how a Group is basically what happens when you refactor the concept of "plus" out of numbers into something more general. (And how a Ring is a Group that also has the "multiply" operation.) And then she shows how many different domains these abstractions apply to -- most of them far more concrete than we usually think of as "math".

The result is a whole language of really, really high-level abstractions. And while they're abstract, they're by no means useless -- these "abstractions" are, from a software POV, basically high-level traits and functions. Turn them into data structures, and you have clean, reusable pieces for your programs. Using the right abstraction can, as always, save you a lot of pointlessly duplicated code. Moreover, she provides all sorts of tools for understanding and manipulating these abstractions. These largely are *not* equations, because Category Theory is operating at a higher level than equations; instead, there are a bunch of formalisms for expressing these concepts graphically.

I'm not going to kid you: the second half of the book is deeper and more difficult than the first. But it's at least as exciting -- the word "illuminating" is the best way I can think of to describe my reaction to it.


The last chapter, What Category Theory Is, is the summation of the whole thing -- a beautiful and passionate exploration of why Math matters. She discusses Belief, Knowledge and Understanding, the differences between them, and how they relate to each other. I find it thoroughly motivating: I think the chapter could simply be titled "Why Math?". She sets mathematics in a thoroughly humanist context -- not so much an abstract for its own sake, but as a way to understand the world, and moreover to *communicate* about the world.

So, to summarize: this is one of the best books I've ever read in the sciences -- clear, fun, and passionate. I wish she lived nearby, because I think I'd love to audit some of her courses...
Tags: reviews

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded