As I mentioned in my previous post, Ephox engineers care a great deal about functional programming and make heavy use of functional programming techniques in all of our products.
At its core, functional programming is an appeal to mathematics. It is an argument that, if we restrict our programming to techniques where mathematical properties hold, then we can make use of the wealth of knowledge and techniques that mathematics provides.
Obviously Logic, Algebra, Set Theory and Type Theory are a programmer’s “bread-and-butter.” These are our day-to-day tools. But functional programming also opens our world up to incredibly powerful abstractions from the field of Category Theory.
Category Theory is a very abstract field of mathematics that deals directly with properties of mathematical structures and the patterns that can be abstracted from them. Many branches of math can be described in terms of Category Theory, so you can consider it as a foundational branch of math. It deals with the foundations of math itself. It’s sometimes called a “meta-math”.
As programmers, we deal extensively with structures, patterns and abstractions. So Category Theory is incredibly useful to us. With sufficiently capable programming languages, we can directly apply its concepts to our abstraction challenges.
It’s easy to get quite far in FP by learning these abstractions directly. Concepts like Monads (more here), Monoids, Functors can all be taught and there is a wealth of material available. But what if you want to go deeper, to actually understand Category Theory itself?
Eugenia Chen’s fantastic book “How to bake pi” (a.k.a. “Cakes, Custard and Category Theory”) is a nice, gentle introduction that sets the scene for Category Theory. Her baking analogies are just beautiful, and the book is a joy to read. I can’t think of a better place to start.
On a more programmer-centric note, Ken Scambler does a great talk on introductory category theory. The diagrams in his slides are really well done, and he’s a great presenter.
But, the best resource I’ve found for learning category theory is the “Category Theory for Programmers” lecture series by Bartosz Milewski. The videos are split into two series – I’ve just finished the first series and it’s utterly amazing. The videos are incredibly well-paced and he nails the programmer’s perspective by tying it to Haskell code. He goes right into the all of the important details, and explains it brilliantly. I’ve found it the perfect bridge between applied functional programming in Haskell/Scala and Category Theory itself. I can’t recommend it highly enough.
Because Category Theory is very abstract, it can be difficult to learn. Personally, I found it to be useful to learn from several different resources. Seeing different perspectives and different explanations helped me to come to an understanding of many of the concepts I’ve discussed in this post. Hopefully, some of the resources I’ve listed above will be helpful to others learning Category Theory.