tags:

views:

742

answers:

3

Was C# compiler written in C++?

+10  A: 

Yes, but there are plans to write a C# compiler in C#, which I believe was discussed in this podcast.

HTH, Kent

Kent Boogaart
Hm, on the surface it sounds silly, kind of like making dog food out of dog food. I'm sure it has merit, though.
Michael Meadows
So what would be used to compile the compiler written in C#? Talk about recursion!
Josh Stodola
lol, that's funny.
Joan Venge
@Josh: the previous version of the compiler. It's iterative, not recursive. They're not using the same version of the compiler to compile itself. Rather, they implement the next version of the compiler using the previous version.
Kent Boogaart
Nothing unusual about that. A large fraction of "serious" languages are eventually bootstrapped to be self hosting.
dmckee
@Kent: I think one of the tests for that compiler must be compiling itself! :)
Hosam Aly
Your objections are non-sense! C compilers nowadays can be perfectly written in C! C# compilers can be written in C#. The only thing that has to be C is the .NET runtime itself!@Kent Boogaart: precisely. And since C# is backwards compatible(usually), it'd be perfectly fine to compile itself.
luiscubal
Seems pointless creating a C# compiler in C#, which is calling C++ anyway (the CLR)
Chris S
@Hosam Actually, this could be the first step to self-awareness. Skynet, here we come!
Michael Meadows
@luiscubal, I think everyone's just having fun with the concept.
Michael Meadows
It is called Bootstrapping and it is fairly common to have a compiler written in the languages own language. It is usually a matter of pride as well and marks a major milestone for the language. http://en.wikipedia.org/wiki/Bootstrapping_(compilers)
Simucal
@Simucal: the link isn't working because the closing parenthesis is not being included in the hyperlink. This one should work: http://en.wikipedia.org/wiki/Bootstrapping_%28compilers%29
Hosam Aly
+4  A: 

Yes.

The Mono C# compiler is written in C#.

Mohannad
+2  A: 

Yes it was - as majority of CLR. If you want to see the internals of CLR and/or compilers I would strongly recommend Shared Source CLI from Microsoft (aka Rotor):

But, there is actually a compiler written in C#. I believe that Mono is written that way. Download Mono sources and find out for yourself.

David Pokluda