Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the main difference between a Compiler and a Transpiler?

What are the main differences between a Compiler and a Transpiler? Please could you provide some examples of both?

like image 481
Dawlatzai Ghousi Avatar asked Nov 15 '16 08:11

Dawlatzai Ghousi


People also ask

What is the difference between transpiler and polyfill?

A polyfill will try to emulate certain APIs, so can use them as if they were already implemented. A transpiler on the other hand will transform your code and replace the respective code section by other code, which can already be executed.

What is Babel transpiler or compiler?

Babel is a free and open-source JavaScript transcompiler that is mainly used to convert ECMAScript 2015+ (ES6+) code into a backwards compatible version of JavaScript that can be run by older JavaScript engines. Babel is a popular tool for using the newest features of the JavaScript programming language.

What is the difference between compiler and translator?

Translators convert a program from one language to another. There are various types of translators such as compiler, interpreter and assembler. A compiler converts the entire high-level language source code into machine code. If there are any syntax or semantic error, the program will not execute.

What is transpiler programming?

A source-to-source translator, source-to-source compiler (S2S compiler), transcompiler, or transpiler is a type of translator that takes the source code of a program written in a programming language as its input and produces an equivalent source code in the same or a different programming language.


1 Answers

They're essentially the same: take source code and transform it to something else.

The difference is that compiler usually produces a directly usable artifact (executable binary of some sort). Example: C (produces binary), C# (produces bytecode).

Whereas transpiler produces another form of source code (in another language, for example), which is not directly runnable and needs to be compiled/interpreted. Example: CoffeeScript transpiler, which produces javascript. Opal (converts ruby to javascript)

like image 145
Sergio Tulentsev Avatar answered Sep 22 '22 15:09

Sergio Tulentsev