Optimizing programs

Simple program gets complex when you make it faster.
Want to encapsulate “optimizations” for clarity, explanation and reuse.
In the compiler? Don’t know if it gets used. Can’t rely on it. Hidden. Someone will “optimize the source” later.
By hand, in the source? Original version lost. Confusing now.
Seperately, in macros? Can’t flip between the transformed versions easily. Hard to debug?

Eg. Drawing a gradient. Incremental computations.

Eg. writing xml and a stylesheet, rather than flat html