What are the main differences between a Compiler
and a Transpiler
? Please could you provide some examples of both?
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.
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.
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.
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With