Why are there four mono C# compilers?

前端 未结 2 1274
日久生厌
日久生厌 2021-02-01 21:00

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 versio

相关标签:
2条回答
  • 2021-02-01 21:50

    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).

    0 讨论(0)
  • 2021-02-01 21:54

    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.

    0 讨论(0)
提交回复
热议问题