Compiler vs Transpiler
Difference between Compiler and Transpiler
Before we begin, First we have to understand what is Higher and Lower level languages. High-level programming languages mean that languages of writing computer instructions in a way that is easily understandable and close to human language, the way it's in syntax or style of code is easily understandable. Whereas, in low-level programming languages, programming is done which is associated with the machine which is complex to learn because it is associated with machine language which every instruction we pass will be in binary format like 0 or 1.
So now let’s come to our main topic Which is the Difference between Compiling and Transpiling.
Compiling:-
In general Compiling means converting human-readable source code into machine understandable code. A general example would be C and C++. The text code is compiled into binary format.
For Example, Java Compiler Converts the
.java file to .class file
Transpilling:-
Transpilling means converting code from one language to another of the same abstraction level. For example, Typescript is a high-level language but after its transpile, it’s turned into JavaScript (another high-level language). Let’s take one more example which is Babel What Babel does is transpile ES6 JavaScript Code into ES5 JavaScript Code.
The benefit of transpiler is you can write one language and still end up with another high-level language.
Let’s see some examples of transpiler:-
ES6 Code :
ES5 Code :
- Babel — To convert ES6 code into backward-compatible versions of Javascript.
The difference between transpiler and compiler is in the level of abstraction in the output. Generally, a compiler produces machine-executable code whereas a transpiler produces another high-level language.
Conclusion:-
There is a whole lot more depth and breadth to compiler and transpiler than what we looked at here, but the goal is to provide an overview of what these terms mean.
Let me your thoughts.