A Basic Just-in-Time Compiler

Dev’s “JIT” for a math puzzle lights up a comment war over what JIT even means

TLDR: A developer built a tiny “just-in-time” compiler for a number puzzle, and commenters erupted over whether it’s real JIT, nitpicking terminology and code style. Another user posted a one-line formula that skips the compiler entirely, turning admiration into a lively mix of pedantry, punchlines, and practical alternatives.

A programmer built a tiny “just-in-time” compiler—think: turning instructions into fast machine code on the fly—to turbocharge a simple number-puzzle, and the internet did what it does best. Some cheered the nerdy flex and loved the peek behind the curtain of how computers run code. But the loudest chorus? The terminology police. One commenter declared that “JIT” traditionally means compiling while a program runs, not before, accusing the post of being more like quick “compile-ahead” than real JIT. Cue a spicy semantics showdown.

Then a curveball: another user dropped a “closed form solution,” basically a one-liner formula that skips the whole compiler stunt entirely. Instant mic drop. Suddenly, the vibe shifted from “cool hack” to “did we just build a rocket to make toast?” Meanwhile, a third thread lit up over the author’s use of “static” (a keep-this-setting-between-uses variable). Was it a harmless oversight or a fundamental misunderstanding? The debate spiraled into “would the optimizer just fix it anyway?” and everyone had a take.

The comments mixed eye-rolls with admiration, plus jokes about “Just-In-Time to argue,” and “the real JIT was the eval we wrote along the way.” Want the drama? Read the article, then dive into the battles on Hacker News and Reddit for the full spectacle.

Key Points

  • The author built a simple x86-64 JIT compiler in C to compute terms of a recurrence relation challenge instead of using an interpreter.
  • A follow-up challenge using Reverse Polish notation prompted a second JIT implementation to handle more complex expressions.
  • Modern OSes enforce page-level memory protections (read/write/execute), enhancing security and catching bugs early.
  • Memory from malloc is not executable, so JIT code must be placed in memory allocated with execute permissions.
  • An instruction buffer (asmbuf) is demonstrated, assuming 4 kB pages, with advice to use sysconf(_SC_PAGESIZE) to determine actual page size; x86-64 may have 4 kB, 2 MB, or 1 GB pages.

Hottest takes

"Following is the closed form solution linked in the article" — possiblywrong
"JIT is overloaded with at least 2 meaning" — kscarlet
"Is it just me or is the author using static wrong?" — MobiusHorizons
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.