logoalt Hacker News

We ported the original Doom to SQL

128 points • by Vaslo • last Saturday at 10:14 PM • 18 comments • view on HN

Comments

bob1029 • today at 10:34 AM

> I was surprised how easy it is to express pretty complicated game logic in SQL. The game logic is just ~5900 lines of SQL.

I still think HN is taking major naps on the capabilities of contemporary SQL.

There are businesses so complicated that maintaining procedural code over the domain is largely infeasible. Implementing business rules in SQL can decompose the problem in ways that allow for a lot more people to interact with it at the same time.

When I was working in semiconductor manufacturing, we relied very heavily on stored procedures and SQL to operate the factory. Very little operational decision logic existed in code. We had hundreds of users who were inspecting and proposing changes to the same set of procedures. Testing this stuff was trivial because we replicated the prod DB every morning and experimented against live data directly. There was no gap between the information of the business and its logic. Most shops are not ran this way. They treat the database like some CRUD retrieval engine instead of the nexus of both the data and logic.

When people advocate for spending big piles of money with Microsoft, Oracle and IBM, they are generally going for something like the above. They want literally one system the business operates inside of. Spreading a solution across 10+ vendors and tools when you could do with one is borderline negligence depending on your role in the organization.

soltanov • today at 6:55 AM

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

➕ show 1 reply
teelinger • today at 10:28 AM

This is the kind of content I want to see on HN! Pure art.

➕ show 1 reply
noduerme • today at 8:09 AM

The game state being a SQL table just kinda triggered a memory of a year of optimization for me. One thing I'm still unsure of being a good decision or a bad one, when I wrote my casino in 2010, was having every remote call update game states on SQL tables that were used as the source of truth. With multiple players you can imagine that there would sometimes be issues. Some of the deadlock problems early on were horrific; scaling was a nightmare. But everything was atomic. No risk of lost data beyond one turn not reaching the server or deadlocking, nothing like a huge nodejs process choking on everyone's calls at the same time, or losing its memory. You always had state.

Looking back it seems like not a terrible design pattern for multiplayer turn-based games, if you can work out the kinks. Atomicity guarantees at least that there is a consistent state that won't get lost. Doing that read/write loop for an action game? Pure folly, but it's pretty funny to me.

➕ show 1 reply
ralfd • today at 7:43 AM

I want to point out that they set up an EU and US multiplayer server! Nice touch.

emsixteen • today at 7:31 AM

Meanwhile I'm too inept to get WordPress to load dynamic content faster than molasses.

jdw64 • today at 9:54 AM

It's fascinating that it can be applied this way.

pmkary • today at 7:56 AM

This should be illegal :)))) Wow!

d--b • today at 8:05 AM

Nice piece of advertisement. Kind of hard to stand out in the world of SQL dbs. That definitely raised eyebrows.

➕ show 1 reply
paul-vernon • 09/23/2026

> The game logic is just ~5900 lines of SQL. While this sounds a lot, it’s definitely less than the original C source code which does the same in about 9000 lines!

Nice

➕ show 1 reply
smalltorch • 09/23/2026

Thats ridiculous I love it. The visual in the bottom right it a great illustration.

webbrainiac • today at 9:37 AM

[flagged]

dang • last Saturday at 10:14 PM

(This has been posted numerous times but none of them made the front page. I've made a new copy of the earliest one that got comments.)

builder_woody • today at 7:06 AM

[flagged]