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?
Asked
Active
Viewed 194 times
0
-
3Roslyn was not the first compiler for either C# *or* VB.NET. – Cody Gray - on strike Aug 13 '17 at 13:24
-
1it would make sense that the very first C# compiler could not have been written in C# – Jonesopolis Aug 13 '17 at 13:43
1 Answers
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
-
1This is generally true, but not applicable in this case. Roslyn could have simply been compiled with the pre-existing C# compiler. – Cody Gray - on strike Aug 15 '17 at 09:15