← Mon, Oct 5 digest

We ported the original Doom to SQL

read article ↗ hn thread ↗

CedarDB engineers ported the 1993 game Doom entirely into SQL, implementing game logic and rendering using complex queries and window functions that run at 35 FPS.

read it Offers a fascinating technical deep dive into abusing SQL query planning, window functions, and bigint packing to execute real-time game logic.

summary

Engineers ported the original 1993 Doom game logic and renderer entirely into CedarDB using SQL. Python handles only input, timing, and frame display, while the database manages the 35 Hz game loop and a custom 89-CTE rendering pipeline. The project uses clever hacks like bigint packing for BSP tree sorting and window functions for visplanes to achieve real-time performance. It serves as both an impressive technical showcase and a brilliant marketing campaign for the database engine.

key points

  1. The game logic runs on a 35 Hz fixed loop using roughly 5,900 lines of SQL, processing monster AI via recursive CTEs and updates.
  2. The rendering pipeline spans 1,300 lines of SQL across 89 CTEs, utilizing bigint packing to simulate Z-buffering and BSP tree traversal.
  3. Python is restricted to a thin client role, handling keyboard input, timing, and blitting the raw 320x200 RGB bitmap returned by the database.

who should read it

Systems programmers, database engineers, and retro-gaming enthusiasts interested in unconventional architectures.

discussion warm

consensus

Commenters overwhelmingly praise the project as brilliant engineering art and clever marketing, expressing awe at SQL's unexpected computational capabilities.

pushback

A few note that putting complex logic or game loops inside a database is generally a nightmare for maintenance and debugging in production.

best comment by soltanov ↗

Less lines of code than vanilla C while abusing query planning as a state machine is peak engineering malpractice. I love it.

It perfectly captures the community's tongue-in-cheek appreciation for pushing a database far beyond its intended design limits.

Generated by an LLM from the article and thread. Check the sources before relying on it.