subroutine
subroutine
English
“A subroutine is a named, reusable piece of code — and the concept that a program could call smaller programs-within-programs transformed software from a series of instructions into a structure of functions, the architecture that all modern code inherits.”
The concept of subroutines emerged in the late 1940s as computer programmers discovered that the same sequences of instructions appeared repeatedly in programs. David Wheeler, a British mathematician working at Cambridge University, is credited with inventing the closed subroutine in 1948 — a chunk of code with a defined entry point and a mechanism to return to where it was called. Wheeler also wrote what may be the first stored subroutine library. His insight was that code, like mathematics, could be modular.
Before subroutines, programs were sequences: do this, then do that, then do the other thing. Every calculation of sine, every sort routine, every input operation had to be written out in full each time it was needed. This was not just tedious — it was error-prone. Debugging the same code in twenty places was twenty opportunities to miss one. The subroutine was the first step toward abstraction: name the operation, call the name.
Grace Hopper, working on the UNIVAC in the early 1950s, developed the first compiler — a program that translated human-readable code into machine instructions. She built a library of subroutines that the compiler could assemble into programs. Hopper's insight was that programmers should write in terms of the problem, not in terms of the machine. Subroutines were the vocabulary of that higher-level language.
The subroutine evolved into the function, the method, the procedure, the lambda — same concept, different terminology across programming languages. In Python, 'def'; in JavaScript, 'function'; in Java, a method in a class. All descend from Wheeler's Cambridge subroutine. Every line of modern software depends on calling smaller units of work by name. The name for the named unit is subroutine.
Related Words
Today
Wheeler's subroutine was the first act of abstraction in computing: naming a process so it can be called without being rewritten. The name stands in for the implementation. You say 'sort the list' and the machine does what sorting requires, invisibly, reliably, as many times as needed.
Every application on every device runs on nested subroutines calling subroutines calling subroutines. A single button press on a smartphone may invoke millions of functions in milliseconds. David Wheeler named a block of code at Cambridge in 1948. That naming is still the fundamental act of software engineering.
Explore more words