Splitting programs up is a bread-and-butter programming technique. It's gotten tons of advanced study.
This note is about one specific type of split: the single-split. Forget compositionality in general. Let's take a look at systems that focus down to just one point. The bottleneck. The choke-point. The megavertex. The NEMA connector. The Isthmus of Panama.
(Image cropped from
this paper
by Tung-Liang Chang)
First let's get our feet planted.
There are powerful principles for constructing programs at work here, applicable all the way from small scripts to gargantuan systems.
What existing vocabulary lets us talk about these situations?
It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures.
Uniform Metaphor: A language should be designed around a powerful metaphor that can be uniformly applied in all areas.
Examples of success in this area include LISP, which is built on the model of linked structures; APL, which is built on the model of arrays; and Smalltalk, which is built on the model of communicating objects. In each case, large applications are viewed in the same way as the fundamental units from which the system is built.
The hourglass model and narrow waist design are the same thing. The "narrow waist" refers to the neck of an hourglass.
According to this video the original source is 👤 Jon Postel splitting up the design of TCP and IP.
It quotes Postel in IEN # 2 from 1977:
We are screwing up in our design of internet protocols by violating the principle of layering. Specifically we are trying to use TCP to do two things: serve as a host level end to end protocol, and to serve as an internet packaging and routing protocol. These two things should be provided in a layered and modular way. I suggest that a new distinct internetwork protocol is needed, and that TCP be used strictly as a host level end to end protocol.
At 3:47 in the video the speaker describes Postel drawing an hourglass and using the term "narrow waist" (emphasis mine):
The starting point for the Internet was John saying, "The structure of our world is this: there's only one piece-- that thing in the middle-- that has to be everywhere. Everything else is sitting on individual hosts or individual wires. The thing that has to be everywhere you want it to be absolutely bulletproof, you want it to be really simple, and you want it to be a foundation that you can build on above and below. And the foundation's not going to ever change, because if it changes everything that rests on it is going to have to change and that's going to really stifle the innovation". So John drew an hourglass and said, "Look this is the way the world should be shaped. We get a narrow waist in the center which has to be everywhere. Above it we can put our transport protocols more the better lots of experimentation. Below it we can put lots of different interfaces the more the better lots of experimentation. In the middle we're going to do this thing that's going to be as simple as we can possibly make it and we're never going to let it change."
So the original hourglass metaphor seems to be for systems that (1) have layered architectures, (2) follow a complex-simple-complex layering, and (3) hope not to have to change the simple layer much.
I heard about the Van Jacobson video above while reading the article The Internet Was Designed With a Narrow Waist.
Let's review our original examples. What follows is just my subjective view, I'd appreciate suggestions.
The Internet has a layered architecture following the hourglass model.
The compiler and the static site examples do as well. Additionally they could be described as multi-stage pipelines.
The Lisp and Unix examples are applications of 🖊️ Perlis Epigram #9 and can be described as following the 🖊️ Uniform Metaphor principle. Unix OSes could also be described as following the hourglass model with bytestreams as the simple layer that applications speak to access OS behavior.
However I wouldn't say that the hourglass model applies to the
Unix ecosystem as a whole. Yes, there are lots of types such as
JSON, XML etc. that are also bytestreams. There are lots of
operations (such as
ag
,
cat
,
less
, etc) on those bytestreams. But no layering is present since both
new types and new bytestream operations are visible to applications.
Thus I wouldn't call this an hourglass model since the system
isn't split into two by a fixed interface.