Live data from Hacker News

Show HN: Onramp Can Compile Doom

ludocode.com

11–20 of 25 posts

Re: Show HN: Onramp Can Compile Doom

#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

Re: Show HN: Onramp Can Compile Doom

#13

From the GitHub for on-ramp: it’s “self-bootstrapping and can compile itself from scratch”. What does that mean? How can it compile itself if it doesn’t exist?

They do go into some detail of the steps involved. Basically, it seems as though the system unravels itself, going from simple things to more complex.

Re: Show HN: Onramp Can Compile Doom

#15
post #13

From the GitHub for on-ramp: it’s “self-bootstrapping and can compile itself from scratch”. What does that mean? How can it compile itself if it doesn’t exist?

They do go into some detail of the steps involved. Basically, it seems as though the system unravels itself, going from simple things to more complex.

Thanks, but perhaps I should have been more clear in my question. How can something self-compile if it doesn't have a compiler to start with? Does the onramp source contain some machine code that is a compiler already?

Re: Show HN: Onramp Can Compile Doom

#16
post #9
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.

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...

Re: Show HN: Onramp Can Compile Doom

#17
post #13

Earlier quoted context omitted.

They do go into some detail of the steps involved. Basically, it seems as though the system unravels itself, going from simple things to more complex.

Thanks, but perhaps I should have been more clear in my question. How can something self-compile if it doesn't have a compiler to start with? Does the onramp source contain some machine code that is a compiler already?

Indeed it does! It all starts with a hexadecimal code which is converted by a tool into the machine code for some simple VM; there seem to be a few more steps, where one thing is used to build another, etc. It is in this sense that this particular system is said to be able to “compile itself.”

Re: Show HN: Onramp Can Compile Doom

#18
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...

To add a bit to this, although Dusk OS doesn't have the same goals as stage0, that is to mitigate the "trusting trust" attack, I think it effectively does it. Dusk OS kernels are less than 3000 bytes. The rest boots from source. One can easily audit those 3000 bytes manually to ensure that there's nothing inserted.

That being said, the goal of stage0 is to ultimately compile gcc and there's no way to do that with Dusk OS.

That being said (again), this README in stage0 could be updated because I indeed think that Dusk is a good counterpoint to this critique of Forth.

Re: Show HN: Onramp Can Compile Doom

#19
post #13

Earlier quoted context omitted.

They do go into some detail of the steps involved. Basically, it seems as though the system unravels itself, going from simple things to more complex.

Thanks, but perhaps I should have been more clear in my question. How can something self-compile if it doesn't have a compiler to start with? Does the onramp source contain some machine code that is a compiler already?

I think the missing piece here is that onramp contains the definition of a very simple virtual machine. One that the reader could implement themselves (though a reference implementation is also provided).

After it incrementally builds on itself all the way up to a fully functional C compiler.

Re: Show HN: Onramp Can Compile Doom

#20
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?
Post reply on HN