Can we use a transpiler instead of a compiler?

Abhijeet EkadAbhijeet Ekad
2 min read

Why do we need a compiler?

In computer programming, we give the computer or to machine certain tasks which we don't want to do again and again and which will reduce our effort in day to day life.

But how do we give the computer that task or order?

We write some code in our preferable language but again the problem is machine doesn't understand our source code. they only understand machine code in which all instructions are given in numbers/binary. so here the compiler comes in the picture. compiler helps to translate source code into machine code. this was the simplest explanation of compiler. ex. converting JavaScript to Binary.

In this process level of abstraction decreases. abstraction means hiding all the unnecessary implementation of the data and showing only the important parts. greater the abstraction the level of language is high. all these high order languages ex. JavaScript, Ruby, Python etc. has more abstraction.

so compiler translates higher abstraction level language into lower abstraction level language.

What is a transpiler?

we write code in many programming languages (python, java,c++, typescript etc.) but browsers only understand javascript. so to run our code smoothly on the browser we need to translate our code into javascript so the transpiler helps us internally to make this happen.

In this case, both languages have high-level abstraction.

Not just javascript but transpiler can convert source code into any higher-order programming language. it is also called a source to source translator.

some examples of transpiler are babel, typescript, CoffeeScript, Kotlin, ClojureScript etc

Can we use a transpiler instead of a compiler?

so you might think that both are translating code in fact transpiler can handle higher-order abstractions also. so why do we use a compiler?

The reason is that the compiler process code and produce something executable but the transpiler process the source code and generate the source code in another language. so that's we cannot use a transpiler instead of a compiler.

you can find me here. Twitter

4
Subscribe to my newsletter

Read articles from Abhijeet Ekad directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Abhijeet Ekad
Abhijeet Ekad