Many programmers read books about new platforms or languages. Perhaps even a book about applying a particular pattern in their favorite language. I like to go deeper and try to understand the fundamental structure that serves as the underpinnings of all programming. The code behind the code, if you will. I have encountered a few books and resources over the last few years that have helped me understand what this thing we call “computation” is really about.
These books and resources go deep; every page has something weighty to chew on. The concepts they cover may seem intimidating, but they are actually quite simple. You need to stick with them and get to the point where there is a shift in your thinking. While I have not (yet) finished any of these, what I have read has already proved fruitful.
The Structure and Interpretation of Computer Programs
By Harold Abelson, Gerald Jay Sussman, and Julie Sussman
SICP is famous enough it almost needs no introduction. The book dives deep into fundamental programming principles before moving on to designing and implementing a programming language. The book uses Scheme, a dialect of Lisp. While the Lisp family has mythical status in the programmer community, it is a straightforward language with a basic structure and syntax that can be learned in a few minutes.
This book is very dense, and it will take a while to understand the contents fully, but it is well worth it. Fortunately, video lectures from the authors are available for free on YouTube to help you get through the material. If you don’t like the authors’ teaching styles, this book has been covered many times on YouTube. The book is available in print and for free under the Creative Commons.
Category Theory for Programmers
By Bartosz Milewski
Category theory examines the underlying structure of mathematics and logic through “objects” and “arrows” (also called “morphisms”). For programmers, category theory can serve as a roadmap to new ways to manipulate code and how different data structures and functions relate. This book answers what things like a “monad” or a “functor” are and why they are essential concepts. Code examples are in Haskell (more on that below) and, much more verbosely, C++.
Like SICP, this book has a series of free lectures on YouTube, and Milewski is an excellent teacher while demystifying this obscure branch of mathematics. This book was also released under the Creative Commons.
Learn You a Haskell for Great Good!
By Miran Lipovaca
Haskell is a reasonably simple functional language that feels more like mathematics than any other language I have seen. In the previous book, Milewski even shows how you can manipulate Haskell functions on paper as though they were algebraic equations!
The Haskell community has actively mined the depths of category theory, making it a good fit for code examples in the previous book. By studying the language, the last book is made more clear. Coincidently, despite being very different languages, Swift was in part influenced by Haskell. It doesn’t take long before you see Haskell’s imprint on Swift.
The book I have selected here is the famous “Learn You a Haskell for Great Good!” The book is easy to read and has been a joy.
Grokking Simplicity: Taming complex software with functional thinking
By Eric Normand
This book takes a more immediately applicative turn than the previous ones. I initially didn’t include this book in this listing as I personally didn’t find it particularly challenging as it primarily reflected my current thinking.
However, Grokking Simplicity keeps coming up as a book that has been influential to others. I can see it as a gentle way to dip your toes into the functional waters, so I’m adding it here as you may find it fruitful.
This book focuses more on writing and refactoring code based on business requirements and largely avoids most concepts from Category Theory and function composition. Instead, Grokking Simplicity focuses on the crucial distinction between “calculations” and “actions” (i.e., pure functions and functions with side-effects), separating your functions into layers with stratified design, first-class functions, and handling asynchronous tasks.
By Brandon Williams and Stephen Celis
Diving into these concepts in functional languages is great, but what about applying these ideas to something more “practical” like Swift? Luckily there is a fantastic set of resources from PointFreeCo.
Brandon Williams and Stephen Celis do a fantastic job in their videos, with very well-done transcripts included, discussing functional programming using Swift. They go over the theoretical concepts, how to implement them in Swift, ask, “what’s the point?” and use the ideas in practical projects.
Some videos and articles are free, and a subscription for access to everything. The content they cover is extensive, so I believe it is well worth the entry price.