I get confused when people try to make a distinction between compiled languages and managed languages. From experience, I understand that most consider compiled languages to be C,C++ while managed languages are Java,C# (There are obviously more, but these are just few examples). But what exactly is the core difference between the two types of languages?

My understanding is that any program, regardless of what language you use is essentially "compiled" into a low-level machine code which is then interpreted, so does that kinda make managed languages a subset of compiled languages (That is, all managed languages are compiled languages but not the other way around)?

  • 2
    this term is coined by Microsoft, in narrow sense Java is managed as well. Almost in all cases we can think of managed languages like of a subset of that one that compiles.Also, this, I believe is related - programmers.stackexchange.com/questions/72446/…
    – shabunc
    Sep 10, 2012 at 9:12
  • Note that there's a huge difference between a language that compiles (statically) the code to something more machine manageable before runtime (like Java) and one that does it at runtime (like Python). One major difference is that statically compiling it before runtime gives the comiler a chance to make some optimizations which may result in hefty speed improvements (like Java's JIT, rearranging the code for branch prediction etc). Sep 10, 2012 at 10:53
  • 7
    @ShivanDragon, a "language" does not compile anything. Its implementation does. And you can compile Python statically (see PyPy or IronPython for example). OTOH, it is really hard to do it efficiently with a dynamically typed language (look up "tracing JIT", "abstract interpretation", etc.)
    – SK-logic
    Sep 10, 2012 at 11:04
  • @SK-logic: agreed, I've said a baddie. I wanted to refer to the platform, not the language. Sep 10, 2012 at 11:06
  • @shabunc Actually I'd say Compiled is a subset of Managed. A Managed language can do anything a compiled language can do (at virtually the same speed), and then more since a Managed language can be compiled. In order to give C the features of a managed language, you'd need to build a "VM" and actually make it a managed language.
    – Bill K
    Sep 10, 2012 at 17:51

4 Answers 4


The difference is not in "compiled" vs. "managed", these are two orthogonal axes. By "managed" they normally mean a presence of a garbage-collected memory management and/or a presence of a virtual machine infrastructure. Both has absolutely nothing to do with compilation and whatever people deem to be opposite to it.

All this "differences" are quite blurred, artificial and irrelevant, since it is always possible to mix managed and unmanaged memory in a single runtime, and a difference between compilation and interpretation is very vague too.

  • 2
    This is what I basically had in mind, but I've come across a lot of people who keeps making this distinction. Thanks for the clear answer.
    – TtT23
    Sep 10, 2012 at 9:26
  • Managed code means having a intermediate language to be taken care of whatever the execution environment you're running on at runtime, right? So that intermediate language (let's say bytecode) has to be produced by a compiler. IMO, that couples "managed" code and "compilation" concept a little bit. However, if the language is "compiled", that doesn't show it yields a managed code (ie. C++ vs Java)
    – zgulser
    Apr 4, 2017 at 9:23
  • 1
    @zgulser, no, intermediate languages are orthogonal. Managed means having a GC integrated with the language runtime. E.g., OCaml runtime is "managed", though it compiles straight to native.
    – SK-logic
    Apr 4, 2017 at 9:49

To quote Wikipedia:

Managed code is a term coined by Microsoft to identify computer program source code that requires and will only execute under the management of a Common Language Runtime virtual machine (resulting in bytecode).

Managed code needs a runtime (like the .NET CLT) to execute.

  • 5
    Managed code has nothing to do with a framework. It needs a runtime that manages memory.
    – Oded
    Sep 10, 2012 at 8:57
  • Perhaps my wording is a bit off, but isn't the .NET framework actually a "common language runtime"?
    – janvdl
    Sep 10, 2012 at 8:58
  • 3
    No. In includes the CLR, but it also includes the Base Class Libraries, the IL specification and more.
    – Oded
    Sep 10, 2012 at 9:00

I think there is a distinction to be made, however it is not necessarily between "Compiled" and "Managed". These are not opposites; a language can be compiled and not managed, or interpreted (not compiled) and managed, or both, or even neither.

A "compiled" language is simply one in which there is a step that transforms the source code written by the developer into some more regular "bytecode" which is what is executed by the machine. The "machine" can be the actual processor, or a "virtual machine" that performs additional operations on the bytecodes to translate them to "native" machine instructions. The antonym for a "compiled" language is an "interpreted" language, in which the source code is transformed into bytecode instructions at runtime, line by line as they are executed, without a compilation step. A hybrid between them is "jitting", from "JIT" (Just In Time), which is usually interpretation as a one-time step by the executing machine; a line of code (or function or source file) is interpreted when first run, but the native instructions produced are kept in memory so the runtime doesn't have to re-do the interpretation again on subsequent executions of that code.

A "managed" language is a language designed to produce programs that are consumed within a specific runtime environment, which almost always includes a bytecode interpreter; a "virtual machine" that takes the program's code and performs some additional machine or environment-specific transformation. The environment may also include memory management, such as a "garbage collector" and other "security" features meant to keep the program operating within its "sandbox" of space and tools, however such features are not the sole domain of "managed" runtimes. Virtually all interpreted languages could be considered managed, because they require the interpreter to be running underneath the lines of "user" code being executed. In addition, JVM and .NET languages (Java, Scala, C#, VB, F#, IronWhatever) are compiled into an intermediate language or IL, which is superficially similar in form and function to a binary assembly language, but doesn't adhere 100% to any "native" instruction set. These instructions are executed by the JVM, or by .NET's CLR, which effectively translates them to native binary instructions specific to the CPU architecture and/or OS of the machine.

So, languages can generally be described as "compiled" or "interpreted", and as "unmanaged" (or "native") and "managed". There are languages that can be described as any combination of these except possible "interpreted native" (which would only be true for hand-written hexadecimal opcodes, where what is written by the developer is what is executed); if you consider the interpretation layer as a "runtime" (which is easy to argue for and hard to argue against), then all interpreted languages are "managed".

If you want to get technical, almost all programs targeting a multitasking OS nowadays are "managed"; the OS will create a "virtual machine" for each program that is running, in which the program thinks (or at least doesn't have to know otherwise) that it is the only thing running. The code may make calls within itself and to other referenced libraries as if that program was the only thing loaded in memory; similarly, calls to allocate RAM and other higher memory to store and manipulate data and control devices are coded as if the entire memory architecture was available. The VM (and the OS behind it) then translates various memory pointers to the actual location of the program, its data, and hooks to device drivers etc. This is most often done by applying a memory offset (each VM gets a block of 2GB or whatever of memory, starting at address X which the program can treat as if that X was address 0) and as such is very cheap to do, but there are other things the OS kernel is responsible for, such as process scheduling and inter-process communication, which are trickier to manage. However, this basic pattern is generally not considered "managed", as the program doesn't have to know that it's being run by a virtual machine and is often still responsible for keeping its allocated memory "clean". A program that was designed to be run on the MS-DOS command line can be run on newer Windows OSes that don't even have the MS-DOS environment underneath them anymore; the program is instead given a "virtual console" environment, and provided it doesn't try to leave this "sandbox" by trying to directly access protected areas of memory, it will run quite happily.

  • 1
    "languages can generally be described as "compiled" or "interpreted"" – No, they can't. Compilation and interpretation are traits of, well, compilers and interpreters not languages. The term "compiled language" doesn't even make sense. If English were a typed language, it would be a type error. Sep 10, 2012 at 23:44
  • 3
    Compilers and interpreters are usually found compiling and interpreting very specific dialects of languages that are designed to undergo either compilation or interpretation. Nobody's compiling JavaScript source code that I know of, and nobody's interpreting C#. The languages are designed to be consumed in one way or the other. As such, it is usually acceptable to refer to the language itself as "compiled" or "interpreted" because the full environment in which the language is utilized involves one of those two steps.
    – KeithS
    Sep 10, 2012 at 23:53
  • en.wikipedia.org/wiki/Compiled_language
    – KeithS
    Sep 10, 2012 at 23:55
  • en.wikipedia.org/wiki/Interpreted_language - "Theoretically, any language may be compiled or interpreted, so this designation is applied purely because of common implementation practice and not some essential property of a language."
    – KeithS
    Sep 10, 2012 at 23:57
  • 1
    @KeithS: I challenge you to name one JavaScript implementation that is in actual use which doesn't have a compiler. TraceMonkey (Firefox, CouchDB), V8 (Chrome, node.js), Squirrelfisch Extreme (Safari, OSX, iOS), Carakan (Opera), Chakra (Internet Explorer), Rhino (JVM), Nashorn (JVM), IronJS (CLI), JScript.NET (CLI), BESEN all have compilers. Some of them even more than one. TraceMonkey, for example, has a compiler which compiles JS to TM bytecode and a second compiler which compiles TM bytecode to native code. V8 has two compilers which compile JS to native code, one fast, one optimizing. Sep 13, 2012 at 14:08

Managed Language in simple terms it is a high-level language that depends on services provided by a run-time environment to execute, such as garbage collection service, that is why it is called managed in general but that is not the only service it uses, and some of these services are security services, exception handling, standard types, it uses Common Language Run-time CLR to execute, like in .Net languages or a virtual environment like Java which uses `Java Virtual Machine JVM.

Unmanaged Language is a low-level language executable directly by the operating system without the need for virtual run-time services or intermediate language, such languages like C, C++, unmanaged code produced by such languages uses library routines that is dynamically linked to the OS to get the code to execute called DLLs (Dynamic Link Libraries), unmanaged code access the memory directly that is why it is faster than managed code, but unless you are building a hardware driver or sophisticated video game you don't really want to use unmanaged languages as it can get dangerous to work with especially with inexperienced developers like the role state with great power comes great responsibility, and that is why managed languages exists to help developers produce extensible code without diving into the bottom of the system, but still you can create mixed code if you need, these articles explain it all:

An Overview of Managed/Unmanaged Code Interoperability

Sample: Mixing Unmanaged C++, C++/CLI, and C# code

Not the answer you're looking for? Browse other questions tagged or ask your own question.