What’s the difference between compiler, transpiler, and interpreter?

Implementations of different programming languages use various techniques to execute the code. Let’s figure out the difference between them.

Compilers

A compiler is a program that translates a high-level language to bytecode or machine code…


This content originally appeared on DEV Community and was authored by DEV Community

Implementations of different programming languages use various techniques to execute the code. Let's figure out the difference between them.

Compilers

A compiler is a program that translates a high-level language to bytecode or machine code.
At the same time, a compiler itself doesn't execute the resulting code. The user has to do it instead.

Examples of compilers: GCC, javac, rustc

Transpilers

A transpiler is similar to a compiler, but it translates source code to another high-level language instead of bytecode/machine code.
A transpiler doesn't execute the resulting code too.

Examples of transpilers: babel, tsc

Interpreters

An interpreter, in turn, takes in the source code and executes it immediately. In other words, it runs it from the source.

Examples of interpreters: Ruby MRI (CRuby), PHP3

The combination

There are a lot of programming languages implementations that use compiling and interpreting techniques together. Robert Nystrom captured such implementations for his "Crafting Interpreters" book.

chart with compilers and interpreters

This combination allows getting the best from both worlds.
The execution will be faster because it's generally easier to optimize bytecode. At the same time, it's more convenient for the user to run source code with a single command.

For example, CPython works like this.

P.S. Follow me on Twitter for more content like this.


This content originally appeared on DEV Community and was authored by DEV Community


Print Share Comment Cite Upload Translate Updates
APA

DEV Community | Sciencx (2022-02-25T17:54:22+00:00) What’s the difference between compiler, transpiler, and interpreter?. Retrieved from https://www.scien.cx/2022/02/25/whats-the-difference-between-compiler-transpiler-and-interpreter/

MLA
" » What’s the difference between compiler, transpiler, and interpreter?." DEV Community | Sciencx - Friday February 25, 2022, https://www.scien.cx/2022/02/25/whats-the-difference-between-compiler-transpiler-and-interpreter/
HARVARD
DEV Community | Sciencx Friday February 25, 2022 » What’s the difference between compiler, transpiler, and interpreter?., viewed ,<https://www.scien.cx/2022/02/25/whats-the-difference-between-compiler-transpiler-and-interpreter/>
VANCOUVER
DEV Community | Sciencx - » What’s the difference between compiler, transpiler, and interpreter?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/25/whats-the-difference-between-compiler-transpiler-and-interpreter/
CHICAGO
" » What’s the difference between compiler, transpiler, and interpreter?." DEV Community | Sciencx - Accessed . https://www.scien.cx/2022/02/25/whats-the-difference-between-compiler-transpiler-and-interpreter/
IEEE
" » What’s the difference between compiler, transpiler, and interpreter?." DEV Community | Sciencx [Online]. Available: https://www.scien.cx/2022/02/25/whats-the-difference-between-compiler-transpiler-and-interpreter/. [Accessed: ]
rf:citation
» What’s the difference between compiler, transpiler, and interpreter? | DEV Community | Sciencx | https://www.scien.cx/2022/02/25/whats-the-difference-between-compiler-transpiler-and-interpreter/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.