Difference between Transpiler and compiler

Difference between Transpiler and compiler

·

2 min read

image (1).jpeg JavaScript cannot be compiled and run because it's an interpreted language that means it is understood by browsers and uses javaScript to render UI.

So you mean javaScript is transpilered and other languages are compiled? You guessed it right but there is a lot to it than that, let's explore it.

Transpiler

Transpiler converts the code into the same abstraction level so that it can be used widely. For example, ES5 was introduced in 2009 and ES6 was introduced in 2015 so most browsers have adapted to ES5 but ES6 is recent and most browsers are yet to adapt. We all know how much we love the sugar layered syntax offered by ES6, so to solve this problem we have babel which converts code from ES6 to ES5 so that we don't have to wait until all the browsers adapt to ES6, this process is called transpiling

image.png

Compiler

Compiler converts the code from one programming language to another so that the code can be executed. For example, a c file is converted to an exe file, Exe file is hard to understand and code by humans so we need the compiler to convert English like programming language to a language that the computer understands.

At first, C file is preprocessed with header files(one of the popular header file is 'stdio.h') which creates '.i ' file that goes into compiler which gives '.obj' file and combining it with library files we get an '.exe 'file

To Summarize

  1. Transpiler converts to the same abstraction level while the compiler converts from one programming language to another to ensure execution.