Native Code(本机代码)已被编译为特定于处理器的机器码的代码。是计算机编程(代码),编译用来运行一个特殊的处理器(如英特尔x86级的处理器)和它的特殊指令集。
本地代码(native code)是计算机编程(代码),编译用来运行一个特殊的处理器(如英特尔x86级的处理器)和它的特殊指令集。如果同一个程序在不同的处理器上执行的话软件就必须能够模拟出旧的处理器的指令。这种情况下,同一个程序是在模拟模式下运行的,这样就会导致它比在本机模式下运行速度慢。(这个程序可以重写并且重新编译这样就可以用新的处理器执行本机模式了。)
本地代码也可以与字节码区分开来(有时候叫做编译代码),这种代码可以在虚拟机上运行(比如JAVA虚拟机)。虚拟机是一个把通用字节码转换成用于特定处理器的本地代码的程序。微软的.NET编译器产生的就是字节码(微软叫它作中间语言)。Java字节码和微软的中间语言都能在执行前被即时编译器编译成高性能的本机代码。
原生代码(native code)Native code is the code whose memory is not "managed", as in, memory isn't freed for you (C++' delete and C's free, for instance), no reference counting, no garbage collection. Managed code, you guessed it, is the code whose memory is free and allocated for you, garbage collection and other goodies.
Native code is compiled to work directly with the OS. Managed code however, is precompiled (bytecode in Java-speak) but is then processed by the Just In Time Compiler(这就是Java的JIT编译器) to native code at runtime. Managed code has the interesting side effect of having the potential of running on different operating systems, because the machine code is not created until the VM actually uses it. This way, you are able to run .NET apps on Windows and also run them on Linux or Mac that have the Mono runtime installed. The portability is not as clean currently as Java is (because of Microsoft's naturally closed architecture), but the concept remains.
If you are running an unmanaged app, the code has been compiled to run for the designated OS/Hardware. Any portability to another OS/instruction set is lost and must be recompiled to execute.
原生代码中间不需要经过任何转换,可以由当前机器执行执行。