Is Babel a compiler or transpiler?

I've been using Babel for some time now, and I always got the impression that Babel was a transporter for converting my ES6 and ES7 JavaScript to ES5 JavaScript, since I was on the assumption that you can technically treat ES5 and ES6 as two different languages.

However, I could not help but notice that the name of the site Babel describes it as a compiler, which, in my opinion, is very different from the transpiler.

Babel website title - 'Babel - The compiler for writing next generation JavaScript

Is Babel a transpiler or compiler or perhaps offers both? Or is the site name simply wrong?

Disclosure: I know this sounds like a very pedantic question, but I am writing documentation regarding Babylon, and I want my description to be accurate

+17
javascript ecmascript-6 babel
May 14 '17 at 9:01 p.m.
source share
3 answers

The definitions of transpiler and compiler are blurred. Both of them translate the program from one language to another, while maintaining the behavior.

We usually call it a “compiler” when it creates an executable binary. However, binary is just another language that can be interpreted by the processor. Each program is "executable" on the corresponding machine.

We usually call it a “compiler” when it produces lower level output than input, for example. C to assembler. Or Java-Java bytecode. Or ES8 to ES5. Wait ... is this really a different level?

Usually we call it a “transporter” when its output is at the same level as the input, for example. Python for JavaScript or vice versa. However, there will always be parts that use abstraction, available in one language, which must be “compiled” to implement a lower level in another language.

So, to answer your questions:

I believe that the compiler is very different from the transpiler.

No.

Is Babel a transpiler or compiler or perhaps offers both?

Yes.

Or is the website name "Babel - the Next Generation JavaScript Compiler" just wrong?

No. This title focuses on the functions of the next generation, that is, higher-level abstractions that really need to be compiled into a completely different way. Despite the fact that the output is still normal, mainly for humans, readable, JavaScript.

I am writing documentation related to Babel and I want my description to be accurate.

In this case, I would use my own terminology from the official site. If you want to compare the tool with others, select your description.

+31
May 14 '17 at 9:37
source share

Transpilers or source compilers are tools that read source code written in one programming language and create equivalent code in another language.

Babylon is a transpiler and compiler, because words can be used interchangeably.

+1
May 14 '17 at 9:37
source share

Babel is a transpiler , which is a special type of compiler , so both terms are technically correct. You can use either on your own.

It is incontrovertible that Babel is the source compiler (aka transpiler) , since its source and target languages ​​are both one of JavaScript:

A source-compiler, transcompiler or transpiler is a type of compiler that takes the source code of a program written in one programming language as its input and creates the equivalent source code in another programming language.

However, not everyone agrees that the difference between the terms is useful, so some people prefer just the “compiler”.

I personally like the difference, because for me it means something about the difference in the level of abstraction from machine langauge between source (input) and target (output) languages. That is, typical “compilers” are translated from languages ​​of a higher level, “decompilers” translate languages ​​from a lower level, and “transpilers” translate languages ​​at similar levels of abstraction.

0
Jan 16 '18 at 23:33
source share



All Articles