What does it mean for software to run natively?

Solution 1:

A software is native to a platform if it was designed to run on that platform.

A platform usually refers to an operating system, but it can also be applied to devices such as the Nintendo Game Boy.

Using the Game Boy as an example, it gets its software from cartridges. These cartridges contain code that runs natively on the Game Boy.

Emulators are a layer that allows software designed for one platform to be run on another. For example, there are emulators that can execute images of Game Boy cartridges and allow you to play Game Boy games on your computer or even your mobile phone.

A compatibility layer is kind of like an emulator. When 64-bit computers and operating systems became mainstream, they needed to be compatible with the existing 32-bit technologies. Since 64-bit and 32-bit architectures are very different, a compatibility layer is often needed to run 32-bit software on 64-bit machines. For 64-bit editions of Microsoft Windows, Microsoft needed to write a compatibility layer so that 32-bit programs would still work on the new 64-bit system. This is why some programs are often installed to a folder called Program Files (x86), where x86 means "32-bit".

Compatibility layers tend to be more intimate with the native system than emulators are. VirtualBox emulates hardware for operating systems*, and the systems that it emulates doesn't have very much direct interaction with the host system. WoW64 is a compatibility layer in that it lets 32-bit programs run on 64-bit Windows in a more integrated way. WoW64 helps make programs compatible rather than emulating them in an isolated environment.

A translation library is a component of compatibility layers. Whenever binary code is running non-natively, a translation library helps redirect foreign, non-native calls to native calls that the system can understand. Assembly programs written for the original TI-83 might not be compatible with the newer TI-83/84 Plus calculators because some calls that made sense in the TI-83's architecture may no longer be valid in the TI-83/84+. A translation library (probably included in shells like MirageOS) ensures that calls for the TI-83 go to the new, updated places in the TI-83/84+ calculators.

Platform-independent code is written in a language that is interpreted by something that usually runs natively. For example, PHP is a programming language that is interpreted and executed by the installed PHP binary, which has already been compiled natively for Windows, Mac, and Unix-based operating systems. The PHP code that web scripters write are independent of the platform, allowing the code to work on multiple operating systems as long as PHP is installed for those operating systems.


Miscellaneous

Corrections

* Thank you, Michael Kjörling, for catching some issues with this answer.

Other

The difference between "native" and "non-native" is not black and white. (Credits to afrazier)

Solution 2:

Native code is usually used as opposite of platform-indepedent code. If you run native software, you are running a compiled binary and not, for instance, a platform-indepedent script such as javascript or Java bytecode. Compiled C or compiled C++ are the good examples of native code.

Solution 3:

There are surprisingly a couple possible answers, but the standard usually is: code compiled to the opcodes for the CPU, and running against the programming libraries of the OS that booted the computer. In this case, most code you run will be native code. Maybe some counter-examples will clear things up.

Java is not native code. It is compiled to an intermediate bytecode, which is then run on the specific chipset. Java can call native code. Eclipse is a great example - for speed, Java calls out to some platform native graphics calls.

If you run WINE, an MS Windows API emulator, that is not native code. Though you're executing code designed for that chipset (x86), you are not running the code for the OS that booted it, but replacement libraries. MAME runs binaries for different CPUs AND operating systems.

Scripts are not native code. They are written in a higher level language which then has to be converted at runtime to code that runs on your CPU.

There are some blurry lines. Your web browser runs as native code,, but it can also run Java (compiled to bytecode) or Javascript (a script interpreted language).