Tools and Process
What Is a Compiler?
A compiler translates source code written by a programmer into machine code or another lower-level form before the program runs.
Definition
A compiler is a program that reads your whole source file and translates it into a form the computer can run, usually machine code or bytecode. The translation happens before the program runs, which is why it is called ahead-of-time compilation.
C, C++, Rust and Go are compiled to machine code. Java and C# are compiled to bytecode, which a virtual machine then runs.
How it works
A compiler works in stages: it splits the text into tokens, checks the grammar (parsing), checks types and meaning, optimizes the code and then generates the output.
Many errors are caught at compile time, before the program ever runs. That is the main safety benefit of compiled, statically typed languages.