Table of contents
No headings in the article.
tl;dr Compiler - A tool that converts computer program written by humans in high level programming languages (C,C++,Java etc) to machine readable instructions for computers in 0s and 1s.
Computers only understand 0s and 1s and the earlier computer programs were written and interpreted in the same fashion. We could send a signal to computer using variation of 0s and 1s (electrical signal, switches, Punch Cards )
What we write and understand - good morning
What computers sees after compilation - 01100111 01101111 01101111 01100100 00100000 01101101 01101111 01110010 01101110 01101001 01101110 01100111
Compilers are interface that allows humans and computers to interact and understand each other's instructions. It has greatly accelerated the pace of innovation in software development.
Some examples of Compilers - Turbo C++ for C++, javac for Java etc,
tl:dr Transpiler - A tool that takes source code as an input in one programming language and produces an equivalent code in the same or another programming language with same level of abstraction.
Transpilers are also called source-to-source translator, source-to-source compiler (S2S compiler), transcompiler.
But why do we need Transpilers ?
Suppose we are using the most updated and current standard of Javascript but majority of browsers still dont support the current standard. And each browser might support different version of Javascript.
It would be a tedious to convert our program in all lower versions manually. Thanks to Transpilers we don't need to worry about this type of scenarios as it would simply convert our source code to source code in desirable versions and languages.
There are different type of transpilers as per the source and target programming language and it used mainly for migration, improving performance and compatibility.
For example Babel which is widely used javascript transpiler to convert ES6 to ES5 and lower versions.
Summary -
Compiler converts source code to machine code.
Transpiler converts our source code to target source code.
#javascript #transpiler #compiler