Skip to content
NorscodeNorscode

The compiler builds itself

ArticleBy the Norscode project

Norscode is self-hosting: the toolchain is written in the language it compiles.

The compiler, the linker and the standard library in Norscode are written in Norscode itself. It sounds circular — how can a language compile itself before any compiler exists? The answer is a process called bootstrapping, and it's worth understanding, because it says something about how finished a language really is.

How a language lifts itself

It starts with a small bootstrap binary — a simple executable that understands just enough Norscode to compile the first, minimal version of the compiler. That version can then compile a slightly richer version, which in turn can compile an even more complete one. Step by step the language lifts itself up from almost nothing, until the full toolchain stands finished — written in the language it itself translates.

The strictest test

A compiler is one of the most demanding programs there is. It's full of text processing, large data structures, tangled logic and no room for ambiguity — one error in one place propagates to everything else. If a language can express its own compiler in a readable way, it has passed a test the vast majority of programs never come close to. That's one of the reasons self-hosting is considered a sign of maturity.

Why it matters to you

That there isn't another language hidden underneath has a practical consequence: whoever knows Norscode can read the whole way from source code to running program. There's no foreign toolchain in another language between you and how your code is actually translated and run. If you want to know how something works, you can follow the trail yourself.

Openness through the whole stack

It also means fewer black boxes to trust blindly. The compiler, the runtime with its capability model, and the standard library are all written in the same readable language. Self-hosting isn't a stunt for bragging — it's a way of making the whole system transparent, from the first bootstrap binary to the finished NCB file you run in production.

A language that builds itself is thereby saying that it's finished enough to be taken seriously.

Related

Back to the overview