What are programming languages written in?
Language vs. implementation
When we say "Python is written in C," we mean CPython, the reference implementation, is written in C. The Python language specification doesn't mandate any implementation language. You could write a Python interpreter in JavaScript, and some people have.
The key terms:
- Language specification, defines the syntax and semantics (e.g., the Python Reference Manual)
- Compiler, translates source code to machine code or bytecode (e.g., javac, rustc, tsc)
- Interpreter / runtime, executes code (e.g., CPython, V8, HotSpot JVM)
- VM (virtual machine), an abstract machine that runs bytecode (JVM, CLR, BEAM)
What popular languages are written in
| Language | Primary implementation | Notes |
|---|---|---|
| Python | C (CPython) | Reference implementation (CPython) is written in C |
| JavaScript | C++ (V8, SpiderMonkey) | Major engines (V8, SpiderMonkey, JavaScriptCore) are written in C++ |
| Rust | Rust (self-hosting) | rustc is self-hosted; originally written in OCaml |
| Go | Go (self-hosting) | Self-hosting since Go 1.5; previously written in C |
| Java | C/C++ (HotSpot JVM) | HotSpot JVM is in C/C++; javac compiler is in Java |
| TypeScript | TypeScript (self-hosting) | tsc is self-hosted in TypeScript |
| Ruby | C (MRI/CRuby) | Reference implementation (MRI) is written in C |
| Haskell | Haskell (GHC) | GHC compiler is written in Haskell |
Why C and C++ are so common
Most production programming language runtimes are implemented in C or C++ because:
- Direct memory control for garbage collectors and allocators
- Predictable performance without a runtime of their own
- Mature tooling and portability across architectures
- Historical: C was the dominant systems language when most early runtimes were written
Four ways a language gets implemented
Across the dataset, almost every language falls into one of four implementation patterns:
- Interpreted, runtime written in C: the classic dynamic-language pattern. Python (CPython), Ruby (MRI), PHP, and Lua all run on interpreters written in C.
- Self-hosting and compiled to native code: the compiler is written in the language itself and emits machine code, often through the LLVM backend. Rust, Go, and Haskell work this way.
- Compiled to a virtual machine: source compiles to bytecode that runs on a VM written in C/C++. Java and Kotlin target the JVM; C# and F# target the .NET CLR.
- Transpiled to another language: the "compiler" emits source in a second language rather than machine code. TypeScript and CoffeeScript transpile to JavaScript, then run on a JavaScript engine.
Self-hosting languages
Some languages' compilers are written in the language itself, called self-hosting. This requires bootstrapping: an initial compiler written in another language, which is then used to compile the self-hosted version. Self-hosting languages: Rust, Go, TypeScript, Haskell, Java (javac).
See: What is compiler bootstrapping? and What is a self-hosting compiler?