Friday, March 11th 2016
Transpilers, transcompilers or source-to-source compilers are types of compilers that translate code from one programming language into equivalent code in another programming language. You know how traditional compilers will compile code from higher level programming languages and compile them down to lower level languages for the CPU to process? Well, similar process here, except instead of going from higher to lower, transpilers typically stay on the same level of abstraction. Some examples of transpilers include Babel, CoffeeScript and TypeScript.
So what are transpilers used for? Many things. Transpilers, such as TypeScript, allow developers to have more choices on how to write their code. For example:
function greeter(person: string) { evaluates to JS as: function greeter(person) {
return "Hello, " + person; return "Hello, " + person;
} }
The expression inside of the argument for that function evaluates, in typescript, to making sure that the argument passed in will be a string and, if not, throws an error.
In summary, transpilers allow developers to use more tools to help write their code using other languages which are on the same level of abstraction (hence 'trans').
No comments:
Post a Comment