Live data from Hacker News

Show HN: Onramp Can Compile Doom

ludocode.com

21–25 of 25 posts

Re: Show HN: Onramp Can Compile Doom

#21
post #9

Earlier quoted context omitted.

Author here. I think my opinion would be about the same as the authors of the stage0 project [1]. They invested quite a bit of time trying to get Forth to work but ultimately abandoned it. Forth has been suggested often for bootstrapping a C compiler, and I hope someone does it someday, but so far no one has succeeded. Programming for a stack machine is really hard, whereas programming for a register machine is compa…

You might get a kick out of DuskOS(baremetal forth system)'s C compiler. https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/doc/co...

Oh, amazing! I've heard of DuskOS before but I didn't realize its C compiler was written in Forth.

Looks like it makes quite a few changes to C so it can't really run unmodified C code. I wonder how much work it would take to convert a full C compiler into something DuskCC can compile.

One of my goals with Onramp is to compile as much unmodified POSIX-style C code as possible without having to implement a full POSIX system. For example Onramp will never support a real fork() because the VM doesn't have virtual memory, but I do want to implement vfork() and exec().

Re: Show HN: Onramp Can Compile Doom

#22
post #11

Fascinating exercise and nice work! Adjacent (resilient, low-level, big-vision, auditable) projects include: http://collapseos.org/ Forth OS, bootstrapable from paper, for z80 https://urbit.org/ standalone, distributed, auditable, provable, minimalist https://justine.lol/ APE (actually portable executable); cosmopolitan libc

Urbit is all that, but it's way stranger than that.

Re: Show HN: Onramp Can Compile Doom

#23
post #8

I wonder what's the author's view on Forth, seems like the role of the bytecode VM here might be interchangeable with a Forth implementation.

Forth is not a convenient VM to target for C compilers because of its numerous idiosyncrasies (e.g. the stacks don't neatly map to what a typical naive C implementation would expect).

Re: Show HN: Onramp Can Compile Doom

#24
post #6

TL;DR: this is an exercise in implementing a C compiler from scratch. "From scratch" here means "without an existing gcc/clang," so consider civilization destruction scenarios, aliens reading our source code, EMP strike that takes out all smart silicon, corporate policy won't let you download development tools, you only have a javascript console and gumption, etc... To do this, you must: 1. Implement a small tool tha…

What is the concern about aliens reading source code?

Our C compilers don’t work on their alien crystal substrate because the ISA is different and they don’t use ASCII, but the point is that if they understand English, this gives them the tools necessary to make a C compiler without too much prework involved.

Re: Show HN: Onramp Can Compile Doom

#25

Earlier quoted context omitted.

You might get a kick out of DuskOS(baremetal forth system)'s C compiler. https://git.sr.ht/~vdupras/duskos/tree/master/item/fs/doc/co...

Oh, amazing! I've heard of DuskOS before but I didn't realize its C compiler was written in Forth. Looks like it makes quite a few changes to C so it can't really run unmodified C code. I wonder how much work it would take to convert a full C compiler into something DuskCC can compile. One of my goals with Onramp is to compile as much unmodified POSIX-style C code as possible without having to implement a full POSIX…

It can't compile unmodified C code targeting POSIX. That's by design. Allowing this would import way too much complexity in the project.

But it does implement a fair chunk of C itself. The idea is to minimize the magnitude of the porting effort and make it mechanical.

For example, the driver the the DWC USB controller (the controller on the raspberry pi) comes from plan 9. There was a fair amount of porting to do, but it was mostly to remove the unnecessary hooks. The code itself, where the real logic happens, stays pretty much the same and can be compiled just fine by Dusk's C compiler.

Post reply on HN