Skip to content

What is the difference between a compiled and an interpreted language

A compiled language is turned into native machine code by a compiler before it runs, whereas an interpreted language is executed directly by an interpreter at runtime. Compiled code runs without the source or compiler present; interpreted code requires the interpreter each time.

Computer Science · Languages


A compiled language is transformed by a compiler into native machine code before execution, while an interpreted language is executed line‑by‑line by an interpreter at runtime. In a compiled workflow the source file is processed once, producing an executable that can run repeatedly without the source or compiler present. Interpreted languages keep the source or an intermediate representation and require the interpreter each time the program runs.

Compilation Process

When you compile a program, the compiler translates every statement into a sequence of CPU instructions and stores them in an object file. The linker then combines object files and libraries into a single binary, such as a Windows .exe or a Linux ELF file. The resulting binary can be launched directly by the operating system, and the CPU executes the pre‑generated instructions without further translation.

Key differences between compiled and interpreted languages

  • Translation time: compile once vs translate each run
  • Performance: compiled code usually runs faster
  • Portability: source is portable, binaries are platform‑specific
  • Debugging: interpreted offers immediate feedback
  • Distribution: compiled can be shipped without source

Running a program in each model

  1. 1Write the source code in your editor
  2. 2Compiled: invoke the compiler → produce an executable → run the executable
  3. 3Interpreted: invoke the interpreter with the source file → interpreter reads and executes each line

Typical characteristics

AspectCompiledInterpreted
Execution speedFast (native)Slower (interpreted)
Startup timeLonger (needs compile)Short (no compile)
Platform dependenceBinary specific to OS/CPUSource portable across platforms
Typical examplesC, C++, RustPython, Ruby, JavaScript

Both models can coexist; many modern languages use a hybrid approach where source is compiled to bytecode and then interpreted or JIT‑compiled. Understanding the trade‑offs helps you choose the right tool for performance‑critical or rapid‑development tasks.

Check yourself

Which statement correctly describes a key advantage of compiled code over interpreted code?

Get this as a lesson built for you

Describe what you are studying and Lernex writes the lesson and the questions around it. Free, and it takes about a minute.

Try it

No account needed to try it.

What people ask next