用 SQL 玩 DOOM 是什么体验?CedarDB 团队写了 5300 行查询语言移植版What is it like to play DOOM in SQL? The CedarDB team wrote a 5,300-line query language port.


AI free token/AI免费积分
用 SQL 玩 DOOM 是什么体验?CedarDB 团队写了 5300 行查询语言移植版

大多数人把 SQL 当作管理数据集的工具,但它本质上也是一门编程语言。CedarDB 的一个团队为了展示 SQL 的极限,把初代《DOOM》完整地移植到了 SQL 里。

项目中 WAD 数据(除引擎外的一切资源)存储在一系列表里,这部分相对简单;真正棘手的是把游戏锁定在 35fps 的时序管理,以及图像渲染。仅渲染流程就用了 1300 行 SQL、89 个公用表表达式(CTE),整个项目约 5300 行 SQL,另加少量 Python 负责键盘输入、计时和生成位图的显示。

有趣的是,DOOM 可能是最适合跑在 SQL 上的游戏:它诞生于独立显卡普及之前,并非真 3D,原版程序员靠大量技巧营造出 3D 错觉——而这些数据变换恰好是 SQL 的强项,几乎像是懂 SQL 的人写出来的渲染器。

项目源代码已在 GitHub 开源。此前 Hackaday 还报道过用正则表达式运行的 DOOM 和用 Microsoft Word 运行的 DOOM——"能跑 DOOM"依然是程序员圈的终极浪漫指标。

本文来源:https://hackaday.com/2026/09/25/abusing-sql-to-play-doom/
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。

Most people treat SQL as a tool for managing datasets, but it is essentially a programming language as well. A team at CedarDB, to demonstrate the limits of SQL, ported the original DOOM entirely into SQL.

In the project, the WAD data (all resources except the engine) is stored in a series of tables; that part was relatively simple. The really tricky part was the timing management that locks the game at 35 fps, and image rendering. The rendering pipeline alone used 1,300 lines of SQL and 89 common table expressions (CTEs); the whole project is about 5,300 lines of SQL, plus a small amount of Python for keyboard input, timing, and generating the bitmap display.

Interestingly, DOOM may be the game best suited to running on SQL: it was born before dedicated graphics cards became widespread, it is not true 3D, and the original programmers relied on a lot of tricks to create the illusion of 3D—and those data transformations happen to be SQL's strength, almost as if the renderer had been written by someone who knew SQL.

The project's source code is open-source on GitHub. Previously, Hackaday also reported on DOOM running with regular expressions and DOOM running in Microsoft Word—"it can run DOOM" remains the ultimate romantic benchmark in the programmer community.

What is it like to play DOOM in SQL? The CedarDB team wrote a 5,300-line query language port.

暂无评论,快来发表第一条评论吧!No comments yet. Be the first!

📮 需求咨询📮 Inquiry