Compiler vs Interpreter vs Transpiler

RBT picture RBT · Aug 31, 2016 · Viewed 14.1k times · Source

During a reactJS session that I was attending, the presenter used a term transpiler for some code conversion/porting happening. I've always used and heard the terms compiler and interpreter when it comes to converting a language code to a runnable form on a computer system/machine. Transpiler is new to me. How is a transpiler different from a compiler or an interpreter and why it is really needed?

Answer

Jim M picture Jim M · Nov 17, 2017

Compiler - compiles code to a lower level code.

Example:

  • "Developer code" -> "Machine code"
  • PHP -> C
  • Java -> bytecode

Transpiler - compiles code to same level of code/abstraction.

Example:

  • "Developer code" -> "Another developer code or version"
  • JavaScript ES2015+ -> JavaScript ES5

Interpreter - interprets code, not really in the same class/league/context with the two above.

Example: php.exe

  • "Your PHP code/scripts inside index.php" -> "Results to html or just like pure index.html"