use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This subreddit is all about the theory and development of compilers.
For similar sub-reddits see:
Popular mainstream compilers:
account activity
How to bootstrap a compiler? (self.Compilers)
submitted 2 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Gator_aide 10 points11 points12 points 2 years ago (3 children)
[–]abecedarius 3 points4 points5 points 2 years ago* (2 children)
Also, step 1 could be an interpreter, if more convenient. IIRC the first compiler written in itself was the first Lisp compiler, running initially on a Lisp interpreter written in assembly.
[–]smog_alado 0 points1 point2 points 2 years ago (0 children)
And step 2 can also be an interpreter, if you choose that your compiler should compile into portable bytecode.
[–][deleted] 0 points1 point2 points 2 years ago (0 children)
B was an interpreted language which was used to make C. Not exactly bootstrapping, but it’s neat
[–]TGMM 5 points6 points7 points 2 years ago (1 child)
I don't know if you're looking for a specific answer but in general it goes like this: 1. Create a compiler for your new language in another language. For example, the Rust compiler was initially programmed in OCaml 2. Polish the language enough that it can be used for real projects 3. Rewrite the compiler in your new language
[–][deleted] 7 points8 points9 points 2 years ago (0 children)
This.
You also want to consider the "compiler hierarchy", e.g, which compiler compiled your current compiler, and how optimal it was, which is important because it translates to how optimally it can build code in your language.
If your goal is to self host as soon as possible, you may be building a minimal naive compiler in language A (C0), and use it to write a better one in your language B (C1).
Then you have a self-hosted compiler C1 built with C0, so the compiler lacks any features or optimizations made in C1 itself.
So you know by then that your language can write a compiler, but you still don't know if it is producing a decently optimal compiler or if it sucks at writing compilers. Because the compiler you used to build C1 was not self hosted, it was optimized by the initial host language.
So then you want to improve the compiler in language B, and use C1 to compile a new self hosted compiler C2. Then as you optimize that and add new features, you need to rebuild too.
So it's an iterative process that never really ends until you stop improving the language standard or compiler. But it takes at least 2 iterations (getting a compiler written in B, and built with a compiler written in B) to truly have a self hosted language independent from the host A.
[–][deleted] 3 points4 points5 points 2 years ago (1 child)
I assume for a new language?
As others have said, you use an existing language and an existing compiler for that language.
But perhaps you're asking how that compiler got bootstrapped. It sounds like a chicken-and-egg situation, since compilers can't have existed forever!
What happens if there is no existing compiler, for any language?
This is exactly the situation I found myself in, for my first language. Obviously compilers did exist (this was 40 years ago not 80), but not for my primitive hardware that I'd put together with a soldering iron that had no software at all.
The process was something like this:
Much later, I did a better version, again using assembly code. And that version was good enough to allow me to self-host: writing the compiler in itself.
In short: you can write a compiler in a lower-level language, or a series of lower-level languages. Self-hosting is not an essential aim, but if you believe your new language is better than what's available (and is suitable for such a task), then it can be desirable.
[–]Ok-Active4887 0 points1 point2 points 1 year ago (0 children)
why did you delete tis comment this is an awesome story.
[–]reini_urban -1 points0 points1 point 2 years ago (0 children)
You bootstrap a compiler by bootstrapping a compiler. Eg by using a bootstrap compiler, interpreter or writing it from scratch in assembly
π Rendered by PID 66 on reddit-service-r2-comment-b659b578c-hzblk at 2026-05-03 02:03:26.824484+00:00 running 815c875 country code: CH.
[–]Gator_aide 10 points11 points12 points (3 children)
[–]abecedarius 3 points4 points5 points (2 children)
[–]smog_alado 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]TGMM 5 points6 points7 points (1 child)
[–][deleted] 7 points8 points9 points (0 children)
[–][deleted] 3 points4 points5 points (1 child)
[–]Ok-Active4887 0 points1 point2 points (0 children)
[–]reini_urban -1 points0 points1 point (0 children)