Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are there four mono C# compilers?

Tags:

mono

This page explains about the four different mono compilers - mcs/gmcs/smcs/dmcs.

To me, it's a little bit weird to have four C# compilers. As normally the newer version of compiler maintains backward compatibility.

I assume that's because of runtime support issues, but Microsoft's C# has one csc.exe that supports all of the runtime versions.

like image 277
prosseek Avatar asked Oct 07 '10 14:10

prosseek


People also ask

What is monoruntime?

The Mono runtime contains a code execution engine that translates ECMA CIL byte codes into native code and supports a number of processors: ARM, MIPS (in 32-bit mode only), SPARC, PowerPC, S390 (in 64-bit mode), x86, x86-64 and IA-64 for 64-bit modes.

What version of C# does mono use?

The Mono C# compiler is considered feature complete for C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0 and C# 6.0 (ECMA) and it has partial support for C# 7. Historically, various version of same compiler existed.

What is MCS C#?

mcs is the Mono C# compiler, an implementation of the ECMA-334 language specification. You can pass one or more options to drive the compiler, and a set of source files. Extra options or arguments can be provided in a response file. Response files are referenced by prepending the @ symbol to the response file name.

What is C# compiler name?

NET Compiler Platform, also known by its codename Roslyn, is a set of open-source compilers and code analysis APIs for C# and Visual Basic (VB.NET) languages from Microsoft.


2 Answers

It's because Mono's compiler is written in C# and uses System.Reflection, which means it can only access mscorlib from the runtime that it's running on. Therefore, for example, smcs doesn't just target 2.1, it actually uses 2.1 corlib, etc.

There have been plan for a while to have *mcs use either Mono.Cecil or Ikvm.Reflection instead of System.Reflection, which would mean there could then be a single mcs compiler with arguments to target different runtimes.

Microsoft's compiler doesn't have this limitation because it doesn't use .NET Reflection (it's written in native code).

like image 113
Mikayla Hutchinson Avatar answered Oct 02 '22 17:10

Mikayla Hutchinson


For the same reason you can still do development in .NET 2.0 with Visual Studio 2005. Sure, you could use VS2010 and start a .NET 4.0 project with only .NET 2.0 code, but some companies are afraid of upgrading frameworks/compiler versions if they already have something working properly.

Just because the new compiler version is backwards compatible does not mean that teams will want to upgrade.

Having the different compiler versions ensures all of Mono's users can still use whatever compiler version they choose and are comfortable with.

  • mcs: compiler to target 1.1 runtime (to be deprecated with Mono 2.8).
  • gmcs: compiler to target the 2.0 runtime.
  • smcs: compiler to target the 2.1 runtime, to build Moonlight applications.
  • dmcs: Starting with Mono 2.6 this command is the C# 4.0 compiler, and references the 4.0 runtime.

Personally, I like upgrading whenever I can, but some companies and teams are unable to do so for some reason or another.

like image 22
Robert Greiner Avatar answered Oct 02 '22 19:10

Robert Greiner