r/ProgrammingLanguages • u/someOfThisStuff • Jun 07 '26
Steps to a self-hosted compiler?
After having programmed in C for a while, I have finally decided to create my own language, very similar to it, in an attempt to fix it for my personal use.
It is my belief that, with some relatively minor tweaks and changes, C could be transformed into a language I am prepared to sink much time programming for. All of this, of course, is my own opinion; though if you are curious, here is a copy of the current draft for the standard: https://pastebin.com/eq1v7K9t
With the goal being to have a completely self-hosted transpiler (so, written in the language itself), I've been wondering how people usually go about this: do they write a sketchy, barely-working patchwork just to get the language "alive", and then code the true compiler? Or is it more common to do things well the first time, even if it means slower progress?
View all comments
Show parent comment
1
u/koflerdavid Jun 13 '26
You can have all of these things without header files. They just complicate everything. For example, they have to be reparsed for every source file that includes them, which led people to come up with precompiled header files. Instead you can make the compiler emit the interface in a machine-readable format, which can serve as input for other compiler calls, linker, IDEs, and documentation processors.