tags:

views:

499

answers:

5

I'm new to Mono and just started recently. Is mono program are compiled from C# to native code to be able to run on several OS?

and also, I saw a screencast on MonoTouch, which tells me that the monotouch (particularly) compile everything down to Native for C# to be able to run on Iphone.

Im quite confuse.

+1  A: 

The core of the Mono project is a JITter for MSIL (the intermediate language produced by the .NET compilers).

Of course, a Just-In-Time Compiler is still a compiler, and you can just take the native code produced by the JIT process and run that later. Depending on the JITter, it might provide facilities explicitly for doing that.

Anon.
+2  A: 

Mono itself will compile to the .NET CLR bytecode, allowing it to execute on any .NET- or Mono-enabled platform. These executables are not made of native machine instructions; they are just-in-time compiled into native code by the runtime on the system executing it. In short, Mono binaries are portable.

As of CocoaTouch, compiling it to native code was necessary because Apple will not allow systems such as Mono on the iPhone. It is an exceptional case; normal Mono programs won't do this.

zneak
+3  A: 

Pretty much all .NET platforms, both Microsoft (including desktop, compact framework, and microframework) and third-party (such as mono) compile everything first to a common intermediate language which is portable, then just-in-time compile during execution to native code. Some have no JIT and simply interpret the IL directly.

Native code is obviously non-portable.

Does that help?

Ben Voigt
+8  A: 

Mono by default compiles to an intermediate bytecode, which is then run on a virtual machine. This byte-code is portable but is not native machine code.

Mono does have an AOT compiler that will produce native images for when bytecode is not an option.

Jimmy
+1  A: 

Yes you can write in c# or other dotnet languages like VB.Net when compiling against Mono. Mono compiles your code to IL (an intermediate language) which you deploy and then gets JIT (just in time) compiled when ran.

Mono can run a number of platforms like Windows, Mac OSX, Linux and even the iPhone. Though with the iPhone implementation, I believe your code is in fact seemlessly compiled to Objective C which is then compiled to native code rather than to IL.

Ben Daniel