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
2009-03-10 16:22:17
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
2009-03-10 16:28:20
So what would be used to compile the compiler written in C#? Talk about recursion!
Josh Stodola
2009-03-10 16:30:09
lol, that's funny.
Joan Venge
2009-03-10 16:30:19
@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
2009-03-10 16:36:56
Nothing unusual about that. A large fraction of "serious" languages are eventually bootstrapped to be self hosting.
dmckee
2009-03-10 16:37:02
@Kent: I think one of the tests for that compiler must be compiling itself! :)
Hosam Aly
2009-03-10 16:40:09
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
2009-03-10 16:40:43
Seems pointless creating a C# compiler in C#, which is calling C++ anyway (the CLR)
Chris S
2009-03-10 16:40:51
@Hosam Actually, this could be the first step to self-awareness. Skynet, here we come!
Michael Meadows
2009-03-10 16:41:51
@luiscubal, I think everyone's just having fun with the concept.
Michael Meadows
2009-03-10 16:42:37
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
2009-03-10 16:48:32
@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
2009-03-10 17:18:09
+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
2009-03-10 16:42:37