The JIT Calculator Challenge
Published on: 2025-07-15 14:14:12
03 Jan, 2025
Advent of code has come and passed, what should I do now with so much free time? Fear not! The JIT calculator challenge is here.
1. The challenge
Back when Rust was in its infancy, the official website featured an example program to showcase the language’s syntax. It was a toy calculator, implemented as an interpreter in 20 lines of code.
Why talk about website archaeology, though? We are not here for nostalgia’s sake, are we? True, but the above introduction is a necessary step to present the JIT calculator challenge: can you modify the toy calculator so it generates machine code and runs that code directly on the CPU? All you need is determination, no magic involved.
In case some of the terms above (e.g. JIT) are obscure to you, I have included a bunch of background knowledge later in this blog post to help you get started.
But before that…
Show me the code!
Here’s the calculator’s source code, taken from the amazing internet archive:
fn main () { // A simple in
... Read full article.