To Understand the difference between a Transpiler and a Compiler, we first need to understand what is a compiler and what is a transpiler.
What Is Transpiler?
A transpiler is also called a transcompiler, a Source to Source translator, Source to Source compiler. As the name indicates, a transpiler is a tool that translates a source code in a programming language to the same or different programming language with a similar level of abstraction.
A good example for Transpiler is the typescript transpiler which converts Typescript code to Javascript. Babel transpiler can also be used for converting ES6 JS code to ES5 JS code Souce code so that it can run in browsers.
What Is Compiler?
A compiler is a computer program that translates computer code written in one programming language to another programming language(generally from high-level language to low-level language). For example, the Java compiler converts the .java file to a .class file.
##What Is The Difference Between Transpiler and Compiler?
S2S or Source to Source Compiler operates between the same level of abstraction whereas compiler translates between different levels of abstraction.
For Example, A Transpiler will convert a code from Java to kotlin whereas a compiler will convert Java into bytecode. Similarly, A Transpiler will convert a code from python to Javascript whereas a compiler will convert a code from Java to bytecode.
This is the basic difference between transpiler and compiler, we can further explore the topic with code. Happy Learning!