Compiler vs Interpreter vs Transpiler

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"

As is mentioned in this Wiki article, it is a type of compiler which translates source code from one programming language to another programming language. The source code might be in some language no longer used, or doesn't support latest hardware/software advancements, or as per programmer's convenience/favoritism.

A VB6 to VB.NET converter can be thought of as a Transpiler. I might think of COBOL to C# / C++ / Java tool as a transpiler.


It is often called 'transpiling', when you translate code with JS-preprocessors like CoffeeScript, TypeScript (you name it) to plain JavaScript. But it really isn't a JS exclusive thing. It applies to all kind of programming languages. Mostly it's just called compiling.

Transpiling is a specific term for taking source code written in one language and transforming into another language that has a similar level of abstraction.

According to https://www.stevefenton.co.uk/2012/11/compiling-vs-transpiling/

So in your case:

  • 'compile' JSX => JavaScript (and HTML), which I think matches the definition above.
  • Therefore it can be called 'transpiling'. Though calling it 'compiling' would also be ok.

Another example:

  • CoffeeScript / TypeScript / ...whatEverScript.. => JavaScript and vice versa.