Read along with the audio summary
Casey Muratori asserts that you should never take library design advice from anyone who has not had to make a living selling a library in a competitive arena. In this podcast episode that came out on September 25, 2024, Muratori shares his thoughts on software library design. By the end, you will learn how to build more effective software libraries by giving users direct control over stable building blocks.
The true test of good design is whether people will pay for it. Selling a library in a competitive market provides crucial, real world lessons. When people are willing to pay for a library, it proves the design solves real problems effectively. You should prioritize library design advice from practitioners with experience in competitive, commercial environments.
Next, you can give users more flexibility by exposing data instead of hiding it. Common object oriented programming principles focus on hiding data, which is also called encapsulation. Muratori argues this is often impractical, and uses the evolution of the Granny 3D animation library to show how an abstract approach failed, while exposing core data structures directly to the user succeeded. Favor exposing stable, well defined data structures over forcing all interactions through restrictive function calls.
This matters because making users write extra code defeats the purpose of a library. People primarily use libraries to save time or because they lack the expertise to implement complex functionality themselves. Design choices that require users to write more code, like subclassing, or modify the source code are often counterproductive. Design your libraries with the end user's primary motivations of saving time and effort in mind.
Finally, a great interface promises stability rather than secrecy. Instead of hiding functionality behind restrictive APIs, a designer must figure out which components can be guaranteed to remain stable. You then promise that stability by exposing those parts as reliable, accessible building blocks.
A library's true value lies in providing fundamental building blocks that users can trust will not change unexpectedly. Your goal is not to hide everything. It's for you to do the work up front to figure out what you can promise, and then promise that. That is what makes a library good.