tags:

views:

177

answers:

3

Hi

is unmanaged code is native code?what is differnece

any boduy help me.


Duplicate: http://stackoverflow.com/questions/855756/difference-between-native-and-managed-code

+4  A: 

Managed code is code that runs under a virtual machine, in other words its memory is "managed" by another program ( C# for example ).

Unmanaged code runs on the underlying architecture without requiring a virtual machine, but it may require a runtime library. ( C for example )

Further Reading: http://en.wikipedia.org/wiki/Managed_code

whoops, heres a Duplicate.

John T
A: 

Managed code is run by the .NET runtime. The CLR thus handles, amongst other things, memory management (aka Garbage collection). Managed binaries is in IL code. This code is not understood directly by the CPU, but is interpreted by the CLR for the CPU. Any environment with CLR can run the managed assemblies.

Unmanaged code is simply regularily compiled code. A series of ASM instructions that is directly understood by the CPU. Runs faster, but has less of a supporting framework and is at birth restricted to a particular set of possible CPUs on which it can possibly run.

Tormod
A: 

I heard a rather nice story one day. If the original person comes by and see this then I will credit him. I am not sure whether he would want me to drop his name.

Unmanaged Code: Imagine some really ripped mean warriors. They have total free reign. They can do whatever they want and go where ever they need to. The only problem is that they poop every where. They poop up the whole place and get poop into places that they shouldn't. This is C/ C++ etc.

Managed Code: These guys are distant relatives. Far more refined. But hardly as fit and mean. In fact they are slighty over weight. They are not allowed to run where ever they want. In fact there is a border keeping them in their little play pen. They also poop, but they were nappies so they don't get poop all over the place. And routinely a small guy comes around and cleans out their nappies. This is Java.

The poop is obviously memory. The boundaries is the VM. The small guy is the garbage collector.

I just can't remember how the portability feature is meant to figure into this story.

uriDium
I also laughed at the casual comment that .NET and MFC programmers can be distinguished at the dinner table because the MFC programmers do not expect the dishes to disappear by themselves.
Tormod