7 ms·
The C# compiler is written in C#, so you can use it anywhere with a .NET runtime. Microsoft doesn't ship a .NET runtime for Linux, so you'll have to use Mono, b
by Locke1689 13y ago
The C# compiler is written in C#, so you can use it anywhere with a .NET runtime. Microsoft doesn't ship a .NET runtime for Linux, so you'll have to use Mono, but if your app is compatible with Mono, you're good to go!
- amaks 13y agoIs Mono able to compile Roslyn?
- Locke1689 13y agoI assume you mean the Mono C# compiler (the one that the Mono team develops). Interestingly, no -- but neither can the native C# compiler (that's what we call the old C# compiler that everyone's using in VS right now)! Why? The C# compiler is bootstrapped, so we actually compile the compiler with the compiler. It just so happens that a while ago we felt we needed a feature so badly for the C# compiler that we introduced it into the C# language (exception filters) and started using it in the compiler immediately. So in order to compile the compiler, you need a C# compiler that supports exception filters, which right now is just the Roslyn C# compiler. Honestly, the feature (and some other small changes we've made) aren't that complicated, so they could be backported to other compilers, but I don't know why you would want to do that.
- deleted 13y ago[deleted]
- maximilianburke 13y agoHeh. A few years ago I was on a small team working on a .NET compiler and runtime -- it compiled MSIL into native code targeting x86 and PowerPC. I remember when working on the part of the compiler that built the exception handling routines running into exception filters and wondering what they were for. We were largely targeting C# as a development environment at the time but ended up implementing them in case anyone wanted to use VB.NET. Funny to see that they're now making their way back into C#, even if it's just in the compiler :)
- Locke1689 13y agoIn certain cases, especially with async, using "throw;" can cause a loss of information in a dump. We want compiler bugs to fail fast -- to immediately crash the compiler for debugging and analysis. By using exception filters we can immediately crash the compiler in erroneous conditions, preserving stack, locals, etc. This isn't just useful for the compiler, but we felt it was necessary for us to make the most reliable, agile product.
- kyllo 13y agoIt should. Here's the Roslyn source, and it looks to be all in C# and VB: http://roslyn.codeplex.com/ http://roslyn.codeplex.com/
- Revex 13y agoHow does something like this happen? How can you write a compiler in the language that it is supposed to be compiling?
- kyllo 13y agoThey wrote the original C# compiler in a different language (probably C++) first. Then they wrote the second C# compiler in C#, and used the first compiler to compile the second compiler. Voila!
- Locke1689 13y agoWe regularly dogfood, so we're on like N iterations of your structure, but that's the idea!
- jevinskie 13y agoCould you ask around the office and find out some of the details about the C# bootstrap process? I would be fascinated to know what language the non-C# compiler was written in and also how long they used/improved the non-C# compiler until they switched to the C# compiler. This source release is so cool!
- Locke1689 13y agoOh, the old compiler is just the currently shipping compiler (i.e., the one in a clean install of VS 2013). We've been using and maintaining it since the beginning. It's written in C++, so we refer to it as the "native compiler." We only stopped bootstrapping using the native compiler about, oh, 6 months ago, since that was when we decided to take a dependency on new language features. The next VS will be the first VS where Roslyn is the default C# compiler.
- jevinskie 13y agoOh I see, I didn't realize the native compiler was being used the whole time. Thank you for the insight!