Compiler
Also known as: code compiler, compilers
A compiler is a program that translates source code written in a programming language, such as C, C++, Rust, or Go, into machine code or another lower-level form that a computer can execute.
It usually translates the whole program before it runs and catches many errors in the process. Interpreted languages, by contrast, are translated as they run. While compilers are invisible to most people, they make it possible for humans to write software in readable languages.
Compiler, explained at three levels
At home
A compiler is like a translator who converts an entire book from English into another language before anyone reads it. The computer then reads the translated version.
At work
Compilers turn developers' code into the apps and systems a business runs, and catch some bugs early.
At home
When you download an app, you usually get compiled code, not the source code. That's why apps are different for Windows, Mac, and ARM devices.
At work
Compiled languages, such as C++, Rust, and Go, usually run faster than interpreted ones. Many modern languages use 'just-in-time' compilation, mixing both approaches.
At home
Compiler error messages can look scary, but they're usually pointing at a typo. In my opinion, reading the first error carefully fixes most problems.
At work
Enable compiler warnings and security hardening flags, use reproducible builds to verify compiled code matches source, and protect build systems, since compromised compilers or pipelines can inject malicious code.
Real-world examples
At home
Thomas wrote his first C program. The compiler flagged a missing semicolon before turning it into a program he could run.
At work
Aisha leads a Vancouver game studio's engine team. Upgrading their compiler and enabling optimizations improved game performance by about 10 percent.
How it compares
| feature | Compiler | Interpreter |
|---|---|---|
| Translates | Whole program before running | Line by line while running |
| Speed | Usually faster programs | Usually slower |
| Error checking | Before running | When reached |
| Examples | C, C++, Rust, Go | Python, JavaScript (traditionally) |
Compilers translate in advance. Interpreters translate on the fly.
For analysts
In software supply-chain discussions, I'd include build tools and compilers. Attacks such as SolarWinds showed that the build process itself can be compromised.
History & origin
Grace Hopper developed the A-0 system in 1952, often called the first compiler, and championed the idea that programs could be written in English-like languages. John Backus's team at IBM delivered the first FORTRAN compiler in 1957, showing compiled code could be nearly as fast as hand-written machine code. The C language and its compilers in the 1970s made Unix portable across computers. Richard Stallman's GNU Compiler Collection (GCC) appeared in 1987, and Chris Lattner began the LLVM project in 2000 at the University of Illinois, which later underpinned Apple's Swift and Rust. In my view, compilers are among the most important and least celebrated inventions in computing.