Managed is the New Native

It used to be that native development referred to compilers outputting code ready to execute on the target CPU. At the time, the pool of possible CPUs was small, and the alternatives where runtime interpretation. Since then a lot has changed. Modern CPUs have multiple modes of execution (protected mode, long mode, etc.) and optionals instruction sets (SSE4a, SSE5, etc.). A “native code” compiler must choose a minimum level to target, ignoring “higher” level functionality available on newer CPUs. This leaves programs unable to take advantage of the latest CPU innovations, and often running in a legacy compatibility mode on the very CPU it targets.

What is more native on the latest 64-bit processor: 32-bit x86 code or intermediate code just-in-time compiled to take advantage of the 64-bit architecture and latest SSE instruction set? Not so simple, is it?

Managed code platforms such as Java and .NET have a “native” advantage that no unmanaged (so called “native code”) compilers can match. Because managed platforms distribute their programs in an intermediate format (Intermediate Language [IL] Assemblies for .NET and Byte-code for Java) the Just-In-Time (JIT) compiler is able to compile the program to specifically target the CPU it is running on. This means the program can scale up or down as necessary on each CPU, even a CPU that wasn’t released when you wrote the code.

A misconception is that managed applications are slower than unmanaged applications, or that managed applications are interpreted at runtime. A managed application is JIT compiled into highly optimized machine code immediately on execution.

The alternative for non-managed compilers is to compile to multiple targets and then provide software emulation for CPU instruction sets on older CPUs. The result is a more bloated program that contains emulation code that is rarely used, or a program that is unable to take advantage of the latest CPU optimizations.

Now that managed is the new native, it leaves developers free to focus on what is really important: A Native User Experience.