Database expert runs Doom in SQL with just 5,900 lines of code

Database expert runs Doom in SQL with just 5,900 lines of code

When you purchase through links on our site, we may earn an affiliate commission. Here’s how it works .

If you're wondering how the heck one runs a game in SQL, it's actually much easier than you imagine, so long as you think like a database architect. The actual frontend displaying the graphics, playing sound, and taking inputs is in Python, but that part acts only like a PC's peripherals — all the math is done inside the database.

The backend is written for the performance-focused, Postgres-compatible RDBMS CedarDB. Much like modern Doom ports, SQLDoom uses two paths: one running at the game's original 35 Hz for handling all the logic, and a separate thread for displaying graphics, interpolating camera position between game updates.

To start, Vogel had to convert the entities in Doom 's WAD package file to databases. That was easier than expected, as the data therein "is highly relational already," with Vogel presenting the example of map levels ultimately being structured in parent-child relationships that are trivial to replicate in plain tables. 1000 lines of Python was all it took.

For the main gameplay loop, Vogel was once again pleasantly surprised that the game logic was easy to convert. The resulting code was 5,900 lines of SQL, compared to the original C source code's 9,000. A lot of the savings came from the fact that whereas one has to iterate over entities with "for" or "while" loops to update values, a simple "UPDATE… WHERE" is enough in SQL to do that in just one statement — and in parallel, no less. As an added bonus, the fact that everything is a row in a database table makes for some trivial instant modifications, like changing weapon characteristics or enemy behavior on-the-fly.

Microsoft Paint used as a 'monitor' to run Doom at up to 35 fps, project released by firm's Azure CTO

AI coder gets Doom running on a custom CPU designed by GPT-5.6 Sol

Key considerations

  • Investor positioning can change fast
  • Volatility remains possible near catalysts
  • Macro rates and liquidity can dominate flows

Reference reading

More on this site

Informational only. No financial advice. Do your own research.

Leave a Comment