I’ve read about bootstrapped compilers, how Java, Go, Typescript etc. compiles itself — but one thing seems off: let’s assume that we use Node.js to write a compiler for a new programming language.
According to Wikipedia, here comes the stage 2. We create a brand new compiler written in language X, and we use the old compiler written in Node.js to process this new compiler. These makes sense, but what I have a hard time understanding is what comes next.
After this first compiler in language X is written, the old compiler can be discarded (quoting) but how is this even possible? Doesn’t the compiler needs to produce Javascript files for Node to understand, and Node environment for the Javascript files to work in? To simplify, I think this process has to be something like this, which will need the source language.
Code in language X -> Compiler written in X -> X code to Node.js code -> Executed in Node.js
Basically, what I’m asking is how a language can compile itself without the source language. Ultimately, won’t the compiler written in that language need source language?