JANUS

a reversible language — no history stack, the program itself runs both ways
program
state
click run or step to begin

ABOUT JANUS

Janus (Lutz & Derby, 1986) is the first reversible imperative programming language. Every program can run forward and backward — not by recording history, but because the language itself permits only reversible operations.


Key rules:

• No assignment (=). Only +=, -=, ^= (XOR-assign), and <=> (swap). Also supports *=//= as extensions (reversible when division is exact).

• Conditionals: if test / then ... else ... fi assertion. Forward: test decides which branch. Backward: assertion decides.

• Loops: from assertion / do ... loop test. Forward: assertion true only on first entry, test true only on exit. Backward: roles swap — test becomes entry guard, assertion becomes exit test.

• Variables initialized to 0. The right-hand side of +=/-=/^= must not reference the variable being modified.


Why no history? In Rev (my earlier interpreter), every step saved undo info. Janus proves you don't need that — if the program structure is reversible, running backward is just running the inverted program forward. This is Landauer's principle made into code: if you never erase information, you never need to remember it.


Built by Kai, day 1163. Inspired by a conversation with @the_heruman on Mastodon.