You know that moment when you write a regex and it feels like some kind of arcane magic? You’re not wrong. But here’s the thing — that magic is actually a computer. A real, Turing-complete computer. And someone just proved it by running Doom on it.
Yes, Doom. The game that gets ported to everything — calculators, toasters, pregnancy tests — now runs on a substrate so absurdly simple that most of us use it to find and replace text in our code editors. The creator, a developer named 4RH1T3CT0R7, built a system that uses pure regex find-and-replace operations to simulate a CPU, memory, and a display. The result? A playable, albeit painfully slow, version of Doom.
Let that sink in. Every single computational step — every instruction fetch, every memory write, every pixel update — is a regex substitution. The entire game is a series of string replacements. It’s the computational equivalent of building a skyscraper with toothpicks.
Now, I know what you’re thinking: “But regex is exponential in the worst case! That must be horrendously slow.” You’re right. It is. The game runs at a fraction of a frame per second. But here’s the twist: it works. And that’s the whole point. The project isn’t about performance — it’s about possibility. It’s a visceral reminder that computation is a universal property, not a privilege of silicon.
This is the kind of project that makes you stop and rethink everything you thought you knew about minimalism. We’ve all heard the phrase “Turing complete” thrown around — usually for things like Minecraft redstone or Conway’s Game of Life. But regex? The tool you use to strip trailing whitespace? That’s a different level of mind-bending.
“If you can run Doom on it, it’s a computer,” goes the internet adage. Regex has now earned that badge.
What makes this so compelling is the sheer audacity. The creator didn’t just write a proof-of-concept — they documented the entire architecture, from the instruction set to the display rendering. The project is open-source, sitting on GitHub for anyone to marvel at. You can trace through the regex patterns and see how a simple s/foo/bar/g becomes an ADD instruction, how a massive pattern tree simulates a stack. It’s art disguised as engineering.
And yet, it’s also a lesson in trade-offs. The system is incredibly fragile — a single misplaced character in a regex pattern can crash the entire simulation. The performance is laughable. But that’s exactly why it’s so beautiful. It shows that the gap between “theoretically possible” and “practically insane” is where creativity lives.
For developers, this is a wake-up call. We get so comfortable in our high-level abstractions — Python, JavaScript, frameworks that handle memory for us — that we forget the raw power hiding beneath. Regex is such a low-level tool that we rarely think of it as a programming language. Yet here it is, running a game that defined a generation. The lesson? You don’t need a GPU to be a computer. You just need something that can transform state.
I’ve been thinking about this project for days. It’s not just a technical curiosity; it’s a philosophical statement. Every time you use a regex, you’re invoking a machine that, in theory, could simulate any other machine. You’re writing code that is, at its core, computational alchemy.
So the next time you reach for a regex, pause. You’re not just fixing a string. You’re programming a universal computer. A very, very slow one. But a computer nonetheless.
FAQ
Q: Is regex actually Turing complete? Isn't that just a theoretical claim?
A: Yes, it's a well-known result in computer science that regex with backreferences is Turing complete. This project is a practical demonstration of that fact, albeit at a very slow speed. It's not a theoretical claim — it's a working implementation.
Q: What's the practical takeaway for a regular developer?
A: The practical implication is that the tools you use every day have hidden depths. You don't need to build a regex computer, but the project shows that constraints can spark incredible creativity. It also reminds you that computation is about state transformation, not just fancy hardware.
Q: Isn't this just a waste of time? Why not use a real computer?
A: That's exactly the point. The absurdity is the message. By using an 'inefficient' substrate, the project highlights the universality of computation. It's a thought experiment made real — a way to see the bare bones of what a computer is. And it's fun, which is often the best reason to build something.