Dandy Alfaz

Dandy Alfaz's Blog

Compiling vs Transpiling

Compiling vs Transpiling

Untuk memahami definisi transpiling dan compiling secara keseluruhan. definisi diatas sebelum pertanyaan yang diajukan masih terlalu umum.

Accepted answer by tapananand


The definition you have quoted above is too general for a beginner to understand completely and so let me just simplify it to something we see practically.

Compiler: is an umbrella term to describe a program that takes source code written in one language and produce a (or many) output file in some other language. In practice we mostly use this term to describe a compiler such as gcc which takes in C code as input and produces a binary executable (machine code) as output.

Transpilers are also known as source-to-source compilers. So in essence they are a subset of compilers which take in a source code file and convert it to another source code file in some other language or a different version of the same language. The ouput is generally understandable by a human. This output still has to go through a compiler or interpreter to be able to run on the machine.

Some examples of transpilers:

Emscripten: Transpiles C/C++ to JavaScript
Babel: Transpiles ES6+ code to ES5 (ES6 and ES5 are different versions or generations of the JavaScript language)
Now, what do they mean by "similar level of abstraction": As I said it compiles/transpiles to a source file, one can argue that assembly language is also a source file and thus gcc is also a transpiler. So, this argument is what this similar level of abstraction voids.

The notion of categorizing languages into lower, middle and higher level is based on the level of abstraction they provide from the actual working of the machine/architecture.

Lower level languages like assembly are very close to the processor architecture i.e. have different instructions for different processors. While C/C++/Java/JavaScript, abstract all this away providing more abstraction.

So, a transpiler compiles to a language that is closer to the language you started with in the terms of this abstraction (or is closer to the level of that language in the lower-middle-higher level language ladder).

Hope this helps!


source https://stackoverflow.com/questions/44931479/compiling-vs-transpiling

  • Silahkan masukan huruf yang tertulis pada gambar di atas dengan benar.

    Isi tulisan akan diterbitkan dan hanya pemilik blog yang dapat menghapusnya.

    削除
    Compiling vs Transpiling
      Komentar(0)