Eugenia Cheng's popular book "The Joy of Abstraction" explores the world of abstract mathematics and category theory. While seemingly esoteric, this branch of math has very relevant applications in software engineering, especially in designing complex systems. This review breaks down the key concepts, links them to coding principles, and shows why math still matters for modern programmers.
Intuition Before Formalism: Building an Abstract Frame of Mind
Mathematics often conjures up images of endless formulas and rigid analytical thinking. Yet in The Joy of Abstraction, Eugenia Cheng shows how math can be creative, visual, and grounded in real world examples. She wants to guide readers to think more abstractly before diving into technical formalisms.
This approach mirrors how we build software systems. As programmers, we leverage layers of abstraction to manage complexity. We use interfaces, wrappers, and pipelines to create modular components. The implementation details are abstracted away behind clean APIs.
Cheng encourages mathematically reluctant readers to approach category theory in this spirit. Category theory provides a framework for modeling relationships and transformations at a high level, separate from the specific objects involved. Similarly in coding, we deal with data structures and functions abstractly, not worrying about their specific runtime values.
So before delving into advanced math, Cheng develops the reader's intuitions. She relates abstract concepts to social issues and everyday experiences that software engineers recognize. This "outside-in" teaching style creates an inclusive on-ramp to mathematical thinking. Once readers accumulate the right mental models, the formal technical matter becomes much more accessible.
Relationships Over Objects: Understanding Connectivity
Once readers have developed an abstract frame of mind, Cheng dives deeper into category theory. At its core, category theory studies connections between objects rather than the objects themselves. This aligns with how we build modular software systems.
In coding, objects have behaviors and relationships that enable flexibility. For example, Python classes inherit behavior from parent classes. Changes to the parent class interface automatically apply across child classes. This connectivity allows code reuse and decomposition into logical units.
Cheng uses the metaphor of guests at a party to illustrate this principle. The party forms a category where guests are objects. But the interesting structure comes from relationships - conversations between guests. We can transform one conversation into another by adding or removing guests.
Likewise in programming, we leverage relationships to transform data flows. An API call wraps underlying database access. A GUI view renders model data for display. We compose streams of map/filter operations to transform data.
By focusing on connections rather than isolated objects, category theory provides insight into building extensible software systems. Components interconnect via simple rules, enabling modular architectures.
Composing and Decomposing: Modularity and Reuse
A key benefit of category theory is understanding how to decompose and recombine components. In software, we aim to build systems from reusable parts that "plug and play" well together.
Cheng relates this to real-world experiences using her concept of "mathematical knitting." Just as knitters create garments by repeating stitching patterns, mathematicians compose systems by applying rules systematically.
In coding, functions and classes act as stitching patterns that transform data flows. We combine them into pipelines, executing each function's logic serially. Alternately, we build class inheritance chains that share common logic.
This modularity enables solving big problems by reduction into simpler pieces. We break down domain logic into services by business capability. We divide monoliths into microservices by workload. This aligns with category theory's focus on understanding relationships between components.
The flexible recombination also supports reuse and maintenance. We isolate components via clean interfaces and rigourous testing. Changes localize to specific services rather than rippling across a tangled architecture. By judiciously decomposing and composing modules, we sustain long-term agility.
Abstraction in Action: Applications for Software Engineers
While category theory may seem far removed from day-to-day programming, its core concepts profoundly influence software design. Principles like abstraction, modular architecture, and component reuse derive from mathematical analysis of connectivity and transformations.
Some direct applications of category theory include:
- Functional programming languages like Haskell use abstractions like monads and functors to chain operations.
- Stream processing frameworks leverage category theory insights on composability and state.
- Domain-driven design approaches model complex business capabilities as interrelated domains rather than technical components.
- Database normalization applies category theoretic ideas like abstraction and modularity.
- Type theory ensures program correctness by formally specifying component interfaces.
So while not all programmers need to deeply study category theory, we benefit indirectly from best practices it inspires. By teaching core mathematical ideas in an intuitive style, Cheng's book provides software engineers a pathway to enhance their coding with abstract thinking.
Learning category theory doesn't instantly make you a better coder. But expanding your mathematical maturity and embracing abstraction gives you deeper insight into building evolvable systems. Just as math is more than rote formulas, quality software is more than hacking together what "just works." By taking the time to understand foundational concepts, we become more thoughtful, creative architects.
Going deeper: Sets for Mathematics
In an earlier book review we introduced the textbook "Sets for Mathematics".
Both "Sets for Mathematics" and Eugenia Cheng's "The Joy of Abstraction" aim to provide intuitive pathways for readers to access advanced mathematical concepts. However, while Cheng focuses specifically on category theory, "Sets for Mathematics" builds foundations starting from set theory and categorical algebra more broadly.
The two books complement each other in helping software engineers strengthen their mathematical maturity. Cheng's writing style and real-world examples make the abstract ideas more accessible. "Sets for Mathematics" offers rigor in formalizing these concepts into precise specifications and theorems.
Both books emphasize mathematical abstraction not as an end in itself, but as a tool to solve problems in the real world.
Together, these books illustrate the relevance of foundational math to software engineering. Concepts like modularity, composability, and logical reasoning have direct applications in analyzing complex software systems. Studying the underlying category theory and set theory builds intuitions that lead to better system design.
Jordan Dimov is an experienced software consultant specializing in business process automation, Python code quality, cloud solutions, software engineering training and AI. With over 20 years in the industry, Jordan helps companies boost their productivity by building high-quality, scalable, bespoke software solutions.
Consulting some of the fastest growing brands in the UK and globally, the founder of A115 has a no-nonsense educational approach to modern enterprise software engineering.
Jordan's expertise spans a wide range of technologies and domains:
* Building cloud-based ETL data pipelines for industries like commodity trading and asset management
* Developing e-commerce platforms, online payment processing, and bespoke invoicing, billing, bookkeeping and accounting solutions
* Creating generative AI applications using Python, FastAPI, HuggingFace models, and vector databases
* Productionising code and optimizing software architecture for performance and reliability
* DevOps and infrastructure-as-code using AWS CDK, Azure, Terraform, and Kubernetes
Some of Jordan's notable projects include:
* A position and P&L visualization tool for Shell's trading desks, saving millions by improving efficiency
* An AWS-based platform for automating power trading auctions at Shell and LimeJump
* A high-throughput trading analytics platform for Centrica using Python, Kafka, and serverless tech
* Building multi-currency e-commerce and payments infrastructure for international expansion for a number of clients
* An innovative SMS parking payments system processing 100K+ transactions daily for the city of Sofia, Bulgaria
With strong communication skills, Jordan excels at understanding complex business needs, defining technical solutions, and leading teams to deliver results. He brings a focus on code quality, software security, and process optimization to every project.
Contact Jordan to discuss how he can help your company leverage technologies like Python, cloud platforms, and AI to solve business challenges and achieve your goals.