AOT vs JIT Compilation
That a JIT is a slower fallback for languages that could not be compiled properly. A JIT has information no static compiler can have, and routinely produces faster code for dynamically typed programs than any ahead-of-time compiler could; what it cannot do is produce it instantly, or for free.
Ahead-of-time compilation
When startup latency matters, when the deployment target forbids generating executable memory, or when you need the same machine code every time for reproducibility.
Just-in-time compilation
When the program is long-running and the useful facts — which types occur, which branches are taken, which call targets are real — only exist at run time.
| Aspect | Ahead-of-time compilation | Just-in-time compilation |
|---|---|---|
| Information available | Source, build flags, and whatever profile you fed it. | Observed types, hot paths, actual call targets, constant fields. |
| Compile cost | Paid at build time, invisible to the user. | Paid in the running process, competing with the program for CPU and memory. |
| Startup | Immediate — the code already exists. | Slow first: interpret or run tier-0 code while profiling accumulates. |
| Wrong assumptions | Cannot speculate, so it does not need a recovery mechanism. | Speculates behind guards and deoptimizes when one fails. |
| Reproducibility | Same input, same bytes — which is what signing and caching need. | Performance varies run to run with what the program happened to do. |
| Deployment constraints | Works where writable-executable memory is forbidden. | Needs it, or an interpreter fallback. |