What, or how. Not both.

My husband likes to say, “You can tell me what to do or how to do it, not both.” If I ask him to clean the garage, he gets to clean it his way.

When we talk to customers, we ask them to explain the problem. What is the need that our software can help meet? If the customer tells us, “Put this field here and store it in the database at this time,” or various other details of the solution, we gently steer the conversation toward the root of the problem. We want them to tell us what problem to solve, and let us solve it.

So it is with declarative programming. Tell the computer what to do, and let it worry about the details of how. Don’t tell it how to filter the list; tell it that you want a filtered list, and let it worry about how or when to create it.

Why? well, maybe the compiler or optimizer or underlying library knows a more efficient way to do it than we do. Or, because when we get all wrapped up in the “how,” we lose track of the “what” and the “why.” If not when we’re writing code, then when we’re reading it: the cognitive load of “how” takes up brain-space we could use for “why.”


Bret Victor mentions this: “Give the computer high-level goals” in his Future of Programming talk forty years ago.

Kathy Sierra talks about cognitive load in her “Your app is making me fat" post. Although: I disagree with the assessment of lowered willpower in people who think hard and then eat chocolate – the brain uses a lot of sugar and those people needed to replenish. Yeah. Chocolate for coders!