Are transpiling techniques different than compiling techniques?

Roger L Costello <costello@mitre.org>
Mon, 11 Oct 2021 13:26:01 +0000

          From comp.compilers

Related articles
Are transpiling techniques different than compiling techniques? costello@mitre.org (Roger L Costello) (2021-10-11)
Re: Are transpiling techniques different than compiling techniques? ak@akkartik.com (Kartik Agaram) (2021-10-11)
Re: Are transpiling techniques different than compiling techniques? Meyer-Eltz@t-online.de (Detlef Meyer-Eltz) (2021-10-12)
Re: Are transpiling techniques different than compiling techniques? j.vankatwijk@gmail.com (jan van katwijk) (2021-10-12)
Re: Are transpiling techniques different than compiling techniques? DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2021-10-12)
Re: Are transpiling techniques different than compiling techniques? DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2021-10-12)
Re: Are transpiling techniques different than compiling techniques? christopher.f.clark@compiler-resources.com (Christopher F Clark) (2021-10-14)
[7 later articles]
| List of all articles for this month |

From: Roger L Costello <costello@mitre.org>
Newsgroups: comp.compilers
Date: Mon, 11 Oct 2021 13:26:01 +0000
Organization: Compilers Central
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="94857"; mail-complaints-to="abuse@iecc.com"
Keywords: question, translator, comment
Posted-Date: 11 Oct 2021 13:55:57 EDT
Accept-Language: en-US
Content-Language: en-US
X-OriginatorOrg: mitre.org

Hi Folks,


Today I learned a new word: transpiling


I looked it up and learned that it is converting one source code to another.
See below.


"Neat!" I thought. "I am converting a military air navigation data format to a
civilian air navigation data format, which is a kind of transpiling, I think.
I wonder if there are techniques specific to transpiling?


Is there a book or tutorial on how to build a transpiler? Are there techniques
unique to transpilers?


/Roger


-----------------------------------------------


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:
1. Emscripten<https://kripken.github.io/emscripten-site/>: Transpiles C/C++
to JavaScript
2. Babel<https://babeljs.io/>: Transpiles ES6+ code to ES5 (ES6 and ES5 are
different versions or generations of the JavaScript language)


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


[Back in the day, the term was "sift", from a translator from Fortran
II to Fortran IV written in 1962. In the late 1960s IBM had a Fortran
to PL/I translator which worked (I used it) but generated ugly code
due to all the places where the semantics of PL/I were almost but not
quite the same as similar looking Fortran constructs:


http://bitsavers.org/pdf/ibm/360/fortran/GC33-2002-2_FORTRAN_To_PL1_Translator_Jan73.pdf


I think you will find two approaches. There's the half-hearted one in which
it translates contstructs into corresponding ones and hopes the differences
don't matter, and the full one that is a real compiler with all of the
usual analyses and a code generator that happens to generate another high
level language. The f2c Fortran to C translator is an example


https://www.netlib.org/f2c/f2c.pdf


-John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.