How in the world is it written in C#? #69421
-
From what I understand, most compilers are written in a lower-level language, like the first C compiler started life as an Assembly compiler, then C++ used C. How does one make a compiler written in the language it compiles? It makes no sense to me. Doesn't a computer just think our code is just text until we compile it down to machine code? If someone could explain this to me, It would be great. Thanks, Gammer0909 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
A compiler simply takes a source language and converts it to a target language. In our case that is taking in c# and spitting it .net IL. Originally our compiler was written in c++. Once we had a working compiler we could then use it to compile c# programs to IL. Later we wrote a compiler in c# to take c# and produce IL. This was originally compiled with the compiler written in c++. However, once at that point we had C# compiler written in c# and we no longer needed the c++ one. This process is called "bootstrapping". -- Note: this is also how we add new language features. The compiler is updated to recognize new language features. We then build the compiler executable that recognizes those features. And when we start using that compilr Executable, then we can start using those new features in the compiler itself. |
Beta Was this translation helpful? Give feedback.
A compiler simply takes a source language and converts it to a target language. In our case that is taking in c# and spitting it .net IL.
Originally our compiler was written in c++. Once we had a working compiler we could then use it to compile c# programs to IL.
Later we wrote a compiler in c# to take c# and produce IL. This was originally compiled with the compiler written in c++.
However, once at that point we had C# compiler written in c# and we no longer needed the c++ one.
This process is called "bootstrapping".
--
Note: this is also how we add new language features. The compiler is updated to recognize new language features. We then build the compiler executable that recognizes tho…