Partial evaluation folded on itself. Specialize an interpreter to one fixed source program and you get that program compiled (1st projection). Specialize the specializer to the interpreter and you get a compiler (2nd). Specialize the specializer to itself and you get a compiler-generator (3rd). One operation — partial evaluation — applied three times.
A generic power(base, exp) loops exp times — it must test and decrement the exponent every call. Specialize it with exp = 3 fixed: the loop unrolls away, leaving straight-line base*base*base with no exponent parameter and no loop test. The interpreter + the fixed program = the compiled program. live demo
“Futamura built a compiler by self-application in 1971” — he stated the projections; no self-applicable partial evaluator existed until 1984–85. cited
Self-application is not required — you can write the compiler-generator (cogen) by hand; and specialization does not always speed things up (over-unrolling bloats code). Futamura, 1971
The generic interpreter and its specialization both run — the specialized one does fewer operations: