Recently, a friend of mine brought out the essential distinction between libraries and frameworks in software engineering.

A library is a small software program that does one thing, does it cleanly, and lets you apply this thing to whatever you want. It lives and dies by the UNIX philosophy and the Keep It Simple Stupid (KISS) principle. At its heart, a library is the digital equivalent of a hammer.

Whereas a framework comes with a whole approach to solving many problems at once, with a common unified and cleaned abstraction. These days the word gets used mostly for web frameworks like React, but it applies whenever the program you use dictates how the full thing must be done (the technical term is inversion of control). So a framework is much more like a massive and complex factory that works amazingly well for a specific type of product, defined in a particular way.

At its core, this dichotomy is between low-level simplicity, which is infinitely composable and easier to use but also requires more repeated work to build larger wholes, and complex abstraction which captures some core patterns and intuitions but forces you to follow its rules and constraints.

This also means that a nice small library can easily live for as long as the programming language it uses exists and is in use, with next to no maintenance, whereas frameworks require armies of developers to update and anticipate the needs of their users, constantly refactoring the architecture and abstraction because any change reverberates everywhere, until users start dropping en masse for the next framework.

What’s unexpected is that this split also captures a core distinction in the practice of science, highlighted by the great Hasok Chang in his masterpiece “Inventing Temperature”: the distinction between middle-level regularities and high-level theories.

Following Herbert Feigl, Chang distinguishes the empirical laws that simply capture and compress some core phenomena (Archimedes’ law of the lever, Snell-Descartes’ law of refraction, the ideal gas law…), which he calls middle-level regularities, from the complex high-level theories that aim to unify and explain all phenomena in a domain (Newtonian Mechanics, Maxwell’s Electromagnetism, Lavoisier’s Chemistry…)

The latter clearly compresses and simplifies much more, giving you an incredible reach on the moment. But Feigl and Chang’s point is that theories tend to get invalidated and replaced by more complex and subtler ones, often built on completely different (incommensurable) abstractions; not so much middle-level regularities, which at worst get clearer bounds on their range of application.

As Chang puts it:

Herbert Feigl emphasized that the stability of empirical science lies in the remarkable degree of robustness possessed by certain middle-level regularities, a robustness that neither sense-data nor high-level theories can claim: ‘‘I think that a relatively stable and approximately accurate basis—in the sense of testing ground—for the theories of the factual sciences is to be located not in individual observations, impressions, sense-data or the like, but rather in the empirical, experimental laws’’ (Feigl 1974, 8). For example, weight measurements using balances rely on Archimedes’s law of the lever, and observations made with basic optical instruments rely on Snell’s law of refraction. These laws, at least in the contexts of the measurements they enable, have not failed and have not been questioned for hundreds of years.

- Hasok Chang, Inventing Temperature, p52

So middle-level regularities act like libraries: always there for you, but never overreaching, leaving you most of the heavy lifting. Whereas theories are frameworks that empower you, but must survive more and more pressure from the experimental data and user needs, until they get at replaced (as emphasized by among others Kuhn and his paradigms).

Maybe one epistemological inspiration we can take from this analogy is to search for the libraries/regularities hidden in our theories, and attempt to carve them out. From these, we might build many theories that will rise and fall, leaving only dust, successors, and a handful of eternal libraries.

New Comment