1. Home
  2. Wookash Podcast

Sep 25, 2024

Does data hiding ruin software libraries?

Casey Muratori

6 min → 1:42

Overview

Casey Muratori explains what makes a software library work in the real world, why hiding data often fails users, and why designers should expose core data structures instead.

3 things to know

Muratori says good libraries expose stable building blocks

Casey Muratori states that a well-designed library should not hide everything, but rather figure out which components can remain stable and expose them as reliable building blocks.

▶ Watch at 3:06

Wookash Podcast: exposing core data gives users direct control

Wookash Podcast contrasts the object-oriented philosophy of hiding data with a data-oriented approach that exposes core data structures to give users more direct control and flexibility.

Muratori: Buying a library proves its design works

Casey Muratori argues that the ultimate test of a software library's design is whether people will pay for it in a competitive market, proving it solves real problems.

More

This proves the design solves real problems effectively.

▶ Watch at 0:01

Also in this episode

Understanding the Library User

The speaker emphasizes that people use libraries primarily to save time or because they don't know how to implement the functionality themselves.

More

Therefore, design choices that require users to write more code (like subclassing) or modify source are often counterproductive.

Quotes

“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.”

▶ Watch at 3:06

“You should never take library design advice from anyone who hasn't had to make a living selling a library in a competitive arena.”

▶ Watch at 0:01

Full summary

Episode Overview

  • Casey Muratori asserts that valid library design advice only comes from those who have successfully sold a library in a competitive market, as this experience provides crucial, real-world lessons.
  • He criticizes common Object-Oriented Programming (OOP) principles like data hiding, arguing they are often impractical for library users who want to either save time or lack the expertise to modify complex internals.
  • Muratori uses the evolution of the "Granny 3D" animation library to contrast a failed, abstract approach with a successful one that exposed its core data structures directly to the user.
  • The discussion highlights that a good library provides stable, well-defined, and accessible building blocks, rather than hiding functionality behind restrictive APIs.

Key Concepts

  • Commercial Viability as a Metric for Good Design: The central idea is that the ultimate test of a library's design is whether people are willing to pay for it in a competitive market. This proves the design solves real problems effectively.
  • Data-Oriented vs. Object-Oriented Library Design: The podcast contrasts the OOP philosophy of hiding data (encapsulation) with a data-oriented approach that exposes core data structures, giving users more direct control and flexibility.
  • Understanding the Library User: The speaker emphasizes that people use libraries primarily to save time or because they don't know how to implement the functionality themselves. Therefore, design choices that require users to write more code (like subclassing) or modify source are often counterproductive.
  • The "Promise" of an API: A well-designed library's job is not to hide everything, but to figure out which components can be guaranteed to be stable and then "promise" that stability by exposing them as reliable building blocks.

Quotes

  • At 00:01 - "You should never take library design advice from anyone who hasn't had to make a living selling a library in a competitive arena." - Muratori establishes his core premise that commercial success is the best filter for good design principles.
  • At 03:06 - "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." - This quote summarizes his philosophy that a library designer's job is to provide a stable, predictable foundation for users, not just abstract away the implementation details.

Takeaways

  • Prioritize library design advice from practitioners with experience in competitive, commercial environments.
  • Design APIs and libraries with the end-user's primary motivations in mind, such as saving time and effort.
  • Favor exposing stable, well-defined data structures over forcing all interactions through restrictive function calls.
  • A library's value lies in providing reliable, fundamental building blocks that users can trust won't change unexpectedly.
  • When a design forces users to modify the library's source code to solve their problem, it may be a sign that the library's abstractions are failing to meet real-world needs.

Watch the full episode 6 min

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.

More from Wookash Podcast

Related Episodes