Futamura Projection

If you search online for Futamura Projection, it will redirect you to the Partial Evaluation Wikipedia page. So how are they related? Partial evaluation is a technique to move some of the runtime work to compile time, thereby speeding up the executable. Futamura projection is to repeatedly apply partial evaluation to an interpreter, thereby creating a JIT compiler.

The following diagrams are based on a talk by Tom Stuart which explains Futamura projections in a way I can understand.

Initial

     Source-->+-------------+
      Input-->| Interpreter |-->Output
              +-------------+

Projection 1

Interpreter-->+-------------+
     Source-->|     PE1     |-->Executable
              +-------------+      .
                                   .
                                   .
                            +-------------+
                     Input->| Executable  |-->Output
                            +-------------+

Projection 2

                            +-------------+<--PE1
                 Compiler<--|     PE2     |<--Interpreter
                    .       +-------------+
                    .
                    .
              +-------------+
     Source-->|  Compiler   |-->Executable
              +-------------+      .
                                   .
                                   .
                            +-------------+
                     Input->| Executable  |-->Output
                            +-------------+

Projection 3

        PE2-->+-------------+
        PE1-->|     PE3     |-->Compiler Generator
              +-------------+      .
                                   .
                                   .
                            +-------------+
                 Compiler<--|   Comp Gen  |<--Interpreter
                    .       +-------------+
                    .
                    .
              +-------------+
     Source-->|  Compiler   |-->Executable
              +-------------+      .
                                   .
                                   .
                            +-------------+
                     Input->| Executable  |-->Output
                            +-------------+


Posted: 2025-12-21
Previous - Next