# Compiler

> A tool that turns all your code into one file you can run.

**Field:** Software Development  
**Category:** Compilers & Runtimes

## Think of it like

Think of it like turning a whole book into French first. Then French readers get the done copy.

## Definition

A compiler is a program that turns source code into a form the computer can run directly. It reads the whole program first and checks it for errors. Then it writes out a new file, often machine code, that runs on its own. The original code is not needed to run it after that. C, C++, Rust and Go use compilers.

## Example

Jack compiles a C file of 5 lines. Out comes a program file of about 16,000 bytes that runs with no compiler around.

## Example code

```console
$ gcc hi.c -o hi
$ ./hi
Hi
```

gcc turns hi.c into a program called hi, which then runs on its own.

## Why it matters

Compiled programs start fast and run fast. Many mistakes are caught before anyone runs the code.

## Common mistake

Thinking that code which builds is right. The compiler checks the grammar, not the logic.

## Three principles

- **Whole program first.** It reads everything before making output.
- **New file out.** The result runs without the source.
- **Errors up front.** Grammar slips stop the build.

## Related terms

- [Interpreter](https://learn.benibix.com/term/development/interpreter)
- [Machine Code](https://learn.benibix.com/term/development/machine-code)
- [Compiled Language](https://learn.benibix.com/term/development/compiled-language)
- [Source Code](https://learn.benibix.com/term/development/source-code)
- [Executable File](https://learn.benibix.com/term/development/executable-file)

## Taught in

- [Compilers and Interpreters](https://learn.benibix.com/learn/development-languages/compilers-and-interpreters): Programming Languages, 2/12

---

Source: https://learn.benibix.com/term/development/compiler
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
