0

Looking at the github repo, I see that roslyn is written in C# and VB, the same languages that it is meant to compile. It would make sense that each version is compiled using the version that came before it but, if that is the case, how was the first ever version compiled?

Thsise Faek
  • 373
  • 1
  • 7
  • 20

1 Answers1

1

Its called bootstrapping

I can tell thats confusing, it's a kind of "the chicken and egg" problem, but it has a rather elegant solution.

In basic terms what you do is make a basic version of the compiler in a pre-existing language compiler.

Using that compiler you compile a compiler code for the language written in itself.

Imagine you write a c# compiler in java, and then you using that compiler written in java to compile and run a compiler written in c# that knows how to compile c#.

But then you say "But what about the first compiler ever, there was no language before that!" its answered here, in short: they wrote a compiler in literal bytes just like a compiler would emit for a cpu to run. after that worked they could theoretically write a compiler in that language.

downrep_nation
  • 432
  • 1
  • 7
  • 16