Compiler
Software that translates high-level code into low-level machine code.
A compiler is software that translates computer code written in one programming language (the source language) into another language (the target language). The name is primarily used for programs that translate source code from a high-level programming language to a low-level programming language, such as assembly language, object code, or machine code, to create an executable program. Compilers are fundamental to modern computing, enabling the use of high-level languages by converting them into instructions that digital computers can execute.
- field
- Computing
- known_for
- Translating high-level programming languages into low-level machine code
- related_software
- Decompilers, source-to-source compilers, language rewriters, compiler-compilers
Lore & Background
Theoretical computing concepts developed during World War II formed the basis of digital modern computing. Primitive binary languages evolved because digital devices only understand ones and zeros. In the late 1940s, assembly languages were created to offer a more workable abstraction. Limited memory capacity of early computers led to substantial technical challenges when the first compilers were designed, so the compiling process needed to be divided into several small programs. The front end programs produce the analysis products used by the back end programs to generate target code. Between 1942 and 1945, Konrad Zuse designed the first algorithmic programming language for computers named Plankalkül. He also envisioned a Planfertigungsgerät to automatically translate the mathematical formulation of a program into machine-readable punched film stock. Between 1949 and 1951, Heinz Rutishauser proposed Superplan, a high-level language and automatic translator. High-level language design during the formative years of digital computing provided useful programming tools for a variety of applications, including FORTRAN for engineering and science, COBOL for business, and LISP for symbolic computation. Some early milestones include May 1952, when Grace Hopper's team at Remington Rand wrote the compiler for the A-0 programming language and coined the term compiler, though the A-0 compiler functioned more as a loader or linker. In 1952, before September, an Autocode compiler developed by Alick Glennie for the Manchester Mark I computer is considered by some to be the first compiled programming language.
Reader's Guide
Compilers are essential in computing because they allow programmers to write code in high-level languages that are easier for humans to understand and maintain, while still producing efficient low-level code that computers can execute. A compiler performs operations such as preprocessing, lexical analysis, parsing, semantic analysis, conversion to an intermediate representation, code optimization, and machine-specific code generation. These phases are implemented as modular components, promoting efficient design and correctness. Compiler implementers invest significant effort to ensure compiler correctness, as program faults caused by incorrect compiler behavior can be very difficult to track down and work around. Compared to interpreters, which execute code without converting it to machine code, a program compiled to native code tends to run faster. Just-in-time compilation allows for native execution speed with a one-time startup processing time cost. Low-level programming languages like assembly and C are typically compiled, especially when speed is a significant concern. In theory, any programming language can be used via either a compiler or an interpreter, but in practice languages tend to be used with only one or the other. Compiler technology evolved from the need for a strictly defined transformation of the high-level source program into a low-level target program, with the compiler viewed as a front end for analysis and a back end for synthesis, and optimization between them producing more efficient target code.
Did You Know?
- The name 'compiler' was coined by Grace Hopper's team in May 1952 for the A-0 programming language, though the A-0 compiler functioned more as a loader or linker.
- A cross-compiler produces code for a different CPU or operating system than the one on which it runs.
- Backus–Naur form (BNF), developed by John Backus and used for the syntax of Algol 60, describes the syntax of sentences of a language and derives from context-free grammar concepts by linguist Noam Chomsky.
- The first unambiguously complete compiler is generally credited to the FORTRAN compiler completed in 1957 by a team led by John Backus at IBM.
The Core Function and Varieties
A compiler is software that takes code written in one programming language and transforms it into another, typically moving from a high-level language down to something a machine can execute—assembly, object code, or raw machine code. Beyond this basic translation role, the compiler family branches into several specialized forms. A cross-compiler targets a different CPU or operating system than the one it runs on, enabling developers to build software for platforms they do not directly inhabit. A bootstrap compiler serves as a temporary bridge, used to compile a more refined and optimized version of itself for a given language. The broader ecosystem also includes decompilers that reverse the flow from low-level to high-level code, transpilers that convert between high-level languages, language rewriters that reshape expressions within the same language, and compiler-compilers that generate compilers or their components in a generic, reusable fashion. This diversity reflects the many practical needs programmers face when bridging the gap between human-readable logic and hardware-level instructions.
The Phases of Compilation
A typical compiler moves source code through a sequence of well-defined stages, often called phases. These include preprocessing, lexical analysis, parsing, semantic analysis (sometimes described as syntax-directed translation), conversion into an intermediate representation, code optimization, and finally machine-specific code generation. Rather than treating this pipeline as a monolithic block, compiler designers generally implement each phase as a separate modular component. This architectural choice promotes both efficient design and correctness, since each transformation from source input to target output can be verified and maintained independently. The stakes of getting these phases right are high: a single fault introduced by incorrect compiler behavior can produce program errors that are extremely difficult to trace and work around. For this reason, compiler implementers invest substantial effort into ensuring their tools behave correctly. The modular, phased approach is what allows the enormous complexity of translating human-written logic into precise machine instructions to be managed in a structured, debuggable way.
Compiler Versus Interpreter
Both compilers and interpreters make source code runnable, but they achieve this through fundamentally different mechanisms. An interpreter executes code directly without first converting it into machine code; some interpreters run the source as-is, while others work with an intermediate form such as bytecode. A program compiled to native code generally runs faster than its interpreted counterpart, whereas bytecode-intermediate environments tend to land in the middle on the speed spectrum. Just-in-time compilation offers a hybrid: native execution speed after a one-time startup processing cost. Low-level languages like assembly and C are typically compiled rather than interpreted, especially when speed is critical, because the close one-to-one correspondence between source and machine code gives programmers fine-grained control over hardware. In theory any language could be handled by either approach, but in practice a language tends to be paired with one or the other. Common Lisp illustrates the flexibility: it can be compiled to Java bytecode, to C code for a second compilation pass, or directly to native machine code.
Origins and Early Milestones
The theoretical groundwork for modern computing was laid by scientists, mathematicians, and engineers during World War II, when primitive binary languages emerged because digital hardware only understood ones and zeros. By the late 1940s, assembly languages offered a more practical abstraction over raw circuit patterns. Early compilers faced severe memory constraints, forcing the compilation process to be split into small front-end and back-end programs. Konrad Zuse designed Plankalkül between 1942 and 1945, envisioning a device to automatically translate mathematical program formulations into machine-readable punched film, though no implementation appeared until the 1970s. Heinz Rutishauser proposed Superplan between 1949 and 1951, later refined by Bauer and Samelson. FORTRAN became one of the first implemented high-level languages and first optimizing compiler, targeting engineering and science. COBOL evolved from A-0 and FLOW-MATIC for business use, while LISP addressed symbolic computation. John Backus's BNF, drawing on Noam Chomsky's context-free grammar ideas, became a standard tool for describing programming syntax and even for auto-generating parts of compilers.
Frequently Asked Questions
What is a Compiler in computing?
A compiler is a piece of software that takes source code written in a high-level programming language and converts it into a lower-level form—such as assembly, object code, or machine code—that a processor can directly execute. It serves as the essential bridge between human-readable code and the binary instructions a digital machine actually runs.
What is a Compiler's primary role in the development pipeline?
Its core job is to translate high-level language constructs into low-level, machine-specific instructions so the resulting program becomes an executable artifact. Without this translation step, the readable syntax of languages like C or Rust would be meaningless to the CPU.
Why is the Compiler considered fundamental to modern computing?
It is the mechanism that makes high-level programming languages practical, letting developers write portable, readable code while the compiler handles the gritty details of producing instructions for a specific hardware target. Every time you run a program written in anything other than raw binary, a compiler (or a closely related tool) performed that critical conversion behind the scenes.
What software is closely related to a Compiler?
Decompilers attempt the reverse direction by reconstructing higher-level code from machine code, while source-to-source compilers and language rewriters transform code from one language or dialect into another. Compiler-compilers, sometimes called compiler generators, are meta-tools that help build entirely new compilers from grammar specifications.
How does a Compiler differ from a decompiler?
A compiler moves in one direction—taking high-level source and producing low-level, executable output—whereas a decompiler works backward, trying to recover something resembling readable source from compiled binary. The forward path is deterministic and well-defined; the reverse path is inherently lossy and approximate.
More in Computing & Digital 1-24
Spotted an error? Know more?
This is a living reference — every entry is fact-audited, and reader corrections feed straight into our audit queue. Suggest an edit · See this site's audit record
