# Compilers and Interpreters

> The two ways source code gets run. What a compiler does before the program starts, what an interpreter does line by line, and scripting languages.

**Course:** [Programming Languages](https://learn.benibix.com/learn/development-languages)  
**Time:** 12 min

**After this lesson you can:**

- Explain what a compiler does
- Explain what an interpreter does
- Say why a language is called a scripting language

## How source code turns into a running program

Source code has to become machine code before a chip can run it. There are two ways to do that. A compiler turns the whole program into machine code first, in a build step. It saves the result as a file you can run. An interpreter reads the source and runs it as it goes, a line at a time, every time.

A compiled language is one that is usually run through a compiler. C, C++, Rust and Go are compiled. The build can take seconds or minutes. Then the program runs fast, because the work of turning words into numbers is already done. The file you hand out is the machine code, not the source.

An interpreted language is one that is usually run by an interpreter. Python and JavaScript are the best known. There is no build step, so you change a line and run it straight away. The cost is speed, since the reading is done while the program runs. The person running it also needs the right tool installed.

Many languages sit in between. Java and C# are compiled, but not all the way to machine code. They become bytecode, a halfway form that a runtime turns into machine code as the program runs. That lets one built file run on any machine that has the runtime.

A scripting language is one built for short programs that do a job for you. One might rename 500 files, or pull the numbers out of a report. These are almost always run with no build step, so a script can be written and run in minutes. Python, the shell and PowerShell are often used this way.

Compiled and interpreted say how a language is usually run. They are not a law. There are tools that build Python first, and tools that run C line by line. When people call a language compiled, they mean its normal tools build it first.

The common mistake is to think compiled always means faster to use. It means faster to run. For a script you run once, the time saved by skipping a build is often bigger than any speed lost while it runs.

## Compiled and interpreted, side by side

|  | Compiled | Interpreted |
| --- | --- | --- |
| When code is turned into machine code | Before it runs, in a build | While it runs |
| Speed when running | Fast | Slower |
| What you hand out | A built file | The source code |
| Examples | C, Rust, Go | Python, JavaScript |

![Two roads from source code to a running program. The top road: C, C++ or Go source goes through a compiler to an executable file of machine code, which runs straight on the operating system and chip. The bottom road: Java or C# source goes through a compiler to bytecode, which a runtime, the JVM or CLR, turns into machine code as it runs.](https://learn.benibix.com/diagrams/dev7-runtimes.svg)

### Example: Jack ships a tool to 40 laptops

Jack writes a small tool for 40 office laptops. His first version is a Python script, but 12 of the laptops have no Python installed.

He rewrites it in Go and compiles it once. He copies one 6 megabyte file to each laptop, and it runs with nothing else installed.

**Words in this lesson:** [Compiler](https://learn.benibix.com/term/development/compiler), [Interpreter](https://learn.benibix.com/term/development/interpreter), [Compiled Language](https://learn.benibix.com/term/development/compiled-language), [Interpreted Language](https://learn.benibix.com/term/development/interpreted-language), [Scripting Language](https://learn.benibix.com/term/development/scripting-language)

**Question:** What does a compiler do?

**Answer:** It turns the whole program into machine code before it runs. A compiler turns the whole program into machine code in a build step. The result can then run on its own, without the source.

---

Source: https://learn.benibix.com/learn/development-languages/compilers-and-interpreters
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.
