Remix.run Logo
Show HN: I built a PHP-to-native compiler (written in Rust); now it runs DOOM(github.com)
2 points by nahime 6 hours ago | 3 comments

Because obviously the first logical step after compiling PHP to ARM64 was rendering DOOM with it.

It renders DOOM E1M1 in real-time. BSP traversal, perspective projection, distance fog, sector lighting, collision detection, step climbing - all PHP, compiled to native, running at 15+ FPS. You walk around the actual shareware WAD.

I can hear you: "but does it run DOOM?". No, it renders DOOM. There's a difference. The imps are safe. For now.

Why PHP? PHP has a simple, approachable syntax that millions of developers worldwide already know. That makes it an ideal bridge to bring web developers closer to systems programming, native binaries, and understanding what happens under the hood, without forcing them to learn an entirely new language first.

Of course, PHP was never designed to parse WAD files or traverse BSP trees. To get here, elephc had to grow beyond standard PHP with compiler extensions: packed class for flat POD records (all the DOOM geometry - vertices, linedefs, sectors, segs - lives in these), buffer<T> for contiguous typed arrays (the hot-path storage that makes real-time rendering possible), ptr for raw memory access, and extern for calling SDL2 directly via FFI. You write PHP, but the data structures "perform" like C (not really yet ;)). You can find everything that's been added on top of standard PHP syntax here: https://github.com/illegalstudio/elephc/tree/main/docs/beyon...

PHP vs DOOM (Video): https://media.nahi.me/illegalstudio/elephc/elephc-doom-3d-mo...

GitHub: https://github.com/illegalstudio/elephc

If this made you smile, exhale sharply through your nose, or question my life choices, consider dropping a on the repo. It's how people find the project, and it makes me mass echo dopamine.

gosingk 5 hours ago | parent [-]

Stared, what tool you use to generate the intro video on the .dev site?

nahime 5 hours ago | parent | next [-]

The doom video is a recording from my screen, the other one has been generated completely by Perplexity Computer ;)

nahime 5 hours ago | parent | prev [-]

Oh, and obviously thank you very much for the star!