Why is this pattern so common? Why do new coders hear about it long before they know what it means?

This is one of those beautiful questions of constraints and degrees of freedom. For example: Why are the laws of electromagnetic and gravitational attraction inverse square laws?

Hint: what would those laws be like if the universe had 2 or 4 spatial dimensions instead of 3?

If someone sees this question and knows the answer they’re probably a good engineer.


At a high level, there are just two constraints with code.

1. People Create It

This requires an environment that’s optimized for developers. Devs want an environment with a tight feedback loop, where the delay between changing code and seeing the effects is short; they want an environment that exposes the code that powers it. They want an environment they control, which means it runs on their machines, and as few other machines as possible. We’ll call this environment development.

2. People Use It

This requires an environment that’s optimized for users. It could be development, but optimizing for developers and users doesn’t work. Users want a robust environment backed by as many machines as needed to accommodate them and another million users, and that hides the code that powers it. We’ll call this environment production.

Finally, users want a production environment that doesn’t break. But with only two environments this isn’t possible. Because dev and prod are necessarily different, devs can’t be sure code that works in dev will work in prod. It has to be tested first. This is done in an environment that’s as similar as possible to production (but cheaper to maintain). This one is called staging.

Analysis of constraints gives insights into all kinds of questions. For example, in popular implementations of nearly all languages, why is source code compiled to bytecode before being interpreted by a VM? Very good answer here