编译的第一个版本的roslyn是什么

时间:2017-08-13 13:20:12

标签: c# vb.net

查看github repo,我看到roslyn是用C#和VB编写的,与编译它的语言相同。有意义的是,每个版本都是使用之前的版本编译的,但是,如果是这样的话,第一个版本是如何编译的?

1 个答案:

答案 0 :(得分:2)

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.