Wire flash
TechDeveloper ports Doom to run on regex at 180 seconds per frame
Editorial responsibility
- No named human review is recorded for this page.
- Source reporting is collected, normalized, translated or condensed automatically when needed.
- Automatically published source-backed update
Developer Artem Lytkin has successfully ported the classic 1992 video game Doom to run using only regular expressions (regex), a text-matching utility language. Lytkin created a 96 MB plain-text string containing virtual CPU registers, RAM, video framebuffer, game data, and I/O components. The regex engine performs approximately 80,000 text substitutions per second, requiring nearly 14 million substitutions to render a single frame, resulting in a frame time of about 180 seconds. Despite the extreme slowness, the output is reportedly byte-identical to the original game. Lytkin implemented memory access using a binary tree structure within regex character-jump instructions to avoid scanning the entire 96 MB string. The project is available on GitHub, and the developer describes playing the game as 'closer to correspondence chess with a shotgun than to a twitch shooter.'
Source report
Running the 1992 classic Doom on the most random hardware has become a popular unofficial programming challenge. We've seen it run on everything from toasters to Anker chargers, and even a pregnancy test. Now, enterprising coder Artem Lytkin has taken it a step further by getting Doom to run in regular expressions (regex).
The Horror of Regex as a Programming Language
Developers may recoil at that sentence — and for good reason. Regular expressions are a utility language used for finding and replacing text. While incredibly powerful, their syntax is often described as "write-only," resembling gibberish. For example:
/.*(\d{4}).*/gThis would find "2026" in the string "Tom's Hardware 2026 articles."
Regex can become exceedingly complex, incorporating conditional statements, character-jumping, and substitution rules. However, this complexity also means regex fulfills all the technical requirements to be considered a programming language.
How It Works
Lytkin leveraged these capabilities to create a 96 MB plain-text string containing:
- Sections for the virtual CPU's registers
- Some RAM
- A video output (framebuffer)
- The game's WAD data
- I/O and other components
Once started, the regex engine begins text-matching and substituting characters within the string. It simulates numbers in each processor register, accesses and writes to "memory," and continues the cycle.
Performance: Spectacularly Slow
As you might expect, this approach is extremely slow:
- ~180 seconds to produce a single frame of game output
- Each frame requires nearly 14 million substitutions
Despite the sluggish pace, Lytkin claims the output is byte-identical to actual Doom running on hardware. You can even control the game with keyboard keys — though as Lytkin poignantly notes, playing it "is closer to correspondence chess with a shotgun than to a twitch shooter."
Technical Details for the Nerdy
Lytkin implemented the memory access portion using a binary tree structure, jumping from "branch" to branch using standard regex character-jump instructions. This avoids scanning the entire 96 MB of text repeatedly just to find the "#M" marker bookending it.
Lytkin noted the challenge wasn't about whether it could be done, but whether the game would run "before the heat death of the universe." The engine fires up 80,000 text substitutions per second.
Resources
- Repository: doom-regex on GitHub
- Demo: Download and run it on your own computer
- Project Website: Demonstrates the regex machine in both visual and text format — mesmerizing to watch, reminiscent of watching defragging utilities in action
Follow Tom's Hardware on Google News or add us as a preferred source to get our latest news, analysis, and reviews in your feeds.
Source
Latest from Tom's HardwareNeutral / independent
Part of this Story
Coder Runs Doom Using Regular Expressions at 180 Seconds Per Frame