SUPPORT THE WORK

GetWiki

source-to-source compiler

ARTICLE SUBJECTS
aesthetics  →
being  →
complexity  →
database  →
enterprise  →
ethics  →
fiction  →
history  →
internet  →
knowledge  →
language  →
licensing  →
linux  →
logic  →
method  →
news  →
perception  →
philosophy  →
policy  →
purpose  →
religion  →
science  →
sociology  →
software  →
truth  →
unix  →
wiki  →
ARTICLE TYPES
essay  →
feed  →
help  →
system  →
wiki  →
ARTICLE ORIGINS
critical  →
discussion  →
forked  →
imported  →
original  →
source-to-source compiler
[ temporary import ]
please note:
- the content below is remote from Wikipedia
- it has been imported raw for GetWiki
{{Distinguish|cross compiler}}{{Program execution}}{{Data transformation}}A source-to-source compiler, transcompiler or transpilerWEB,weblink transcompiler - Wiktionary, en.wiktionary.org, 2019-01-08, is a type of compiler that takes the source code of a program written in one programming language as its input and produces the equivalent source code in another programming language. A source-to-source compiler may perform a translation of a program at roughly the same level like from Pascal to C, while a traditional compiler translates from a language like C to Assembler or Java to Bytecode. An automatic parallelizing compiler will frequently take in a high level language program as an input and then transform the code and annotate it with parallel code annotations (e.g., OpenMP) or language constructs (e.g. Fortran's forall statements).WEB,weblink Types of compilers, 1997–2005, compilers.net, 28 October 2010, Another purpose of source-to-source-compiling is translating legacy code to use the next version of the underlying programming language or an API that breaks backward compatibility. It will perform automatic code refactoring which is useful when the programs to refactor are outside the control of the original implementer (for example, converting programs from Python 2 to Python 3, or converting programs from an old API to the new API) or when the size of the program makes it impractical or time consuming to refactor it by hand.Transcompilers may either keep translated code structure as close to the source code as possible to ease development and debugging of the original source code, or may change the structure of the original code so much that the translated code does not look like the source code.WEB,weblink Transparent Compilation, February 12, 2013, February 13, 2013, Fowler, Martin, There are also debugging utilities that map the transpiled source code back to the original code; for example, the JavaScript Source MapWEB,weblink Source Map Revision 3 Proposal, 11 February 2011, Lenz, Fitzgerald, standard allows mapping of the JavaScript code executed by a web browser back to the original source in a transpiled-to-JavaScript language.WEB,weblink Introduction to JavaScript Source Maps, html5rocks.com, 21 March 2012, 21 January 2015, Seddon, Ryan, Examples of transcompiled languages include Closure Compiler, CoffeeScript, Dart, Haxe, TypeScript and Emscripten.WEB,weblink HTML5 Epic Citadel, Epic Games, Mozilla,

{{Anchor|XLT86|TRANS}}History

One of the earliest programs of this kind was Digital Research's XLT86 in 1981, a program written by Gary Kildall, which translated .ASM source code for the Intel 8080 processor into .A86 source code for the Intel 8086. Using global data flow analysis on 8080 register usage, the translator would also optimize the output for code size and take care of calling conventions, so that CP/M-80 and MP/M-80 programs could be ported to the CP/M-86 and MP/M-86 platforms automatically. XLT86 itself was written in PL/I-80 and was available for CP/M-80 platforms as well as for DEC VMS (for VAX 11/750 or 11/780).BOOK, Digital Research, Digital Research, 1981, XLT86 - 8080 to 8086 Assembly Language Translator - User's Guide, Digital Research Inc., Pacific Grove, CA, USA,weblink 2016-11-18, no,weblink" title="web.archive.org/web/20161118230700weblink">weblink 2016-11-18, A similar, but much less sophisticated program was TRANS.COM, written by Tim Paterson in 1980 as part of 86-DOS. It could translate some Z80 assembly source code into .ASM source code for the 8086, but supported only a subset of opcodes, registers and modes, often still requiring significant manual correction and rework afterwards. Also it did not carry out any register and jump optimizations.Seattle Computer Products (1980): 86-DOS - Disk Operating System for the 8086. User's manual, version 0.3 - Preliminary. Seattle Computer Products, Seattle (weblink).WEB, Tim|Cfront|C++|Babel|ClojureScript|Clojure|JSweet|Swiftify|Objective-C|J2ObjC
authorlink1=Tim Patersonurl=http://www.computerhistory.org/atchm/microsoft-research-license-agreement-msdos-v1-1-v2-0/Computer History Museum, Microsoft>date=2013-12-19accessdate=2014-03-25, (NB. While the publishers claim this would be MS-DOS 1.1 and 2.0, it actually is SCP MS-DOS 1.25 and TeleVideo PC DOS 2.11.)

Programming language implementations

The first implementations of some programming languages started as transcompilers, and the default implementation for some of those languages are still transcompilers. In addition to the table below, a CoffeeScript maintainer provides a list of languages that compile to JavaScript.WEB,weblink List of languages that compile to JS, 2018-03-11, {| class="wikitable"
C (programming language)>C
HipHop for PHP>HipHop for PHP (HPHPc)|PHP|C++
JavaScript>Javascript ES6|Javascript ES5
JavaScript>Javascript
Java (programming language)>Java TypeScript>Typescript
Swift (programming language)>Swift
Java (programming language)>Java|Objective-C

Porting a codebase

When developers want to switch to a different language while retaining most of an existing codebase, it might be better to use a transcompiler compared to rewriting the whole software by hand. Depending on the quality of the transcompiler, the code may or may not need manual intervention in order to work properly. This is different from "transcompiled languages" where the specifications demand that the output source code always works without modification. All transpilers used to port a codebase will expect manual adjustment of the output source code if there is a need to achieve maximum code quality in terms of readability and platform convention.{| class="wikitable collapsible collapsed"! Tool !! Source language !! Target language !! CommentsHistory of Python#Timeline and compatibility>2to3 script Python (programming language) 2 >| Even though 2to3 does its best at automating the translation process, further manual corrections are often needed.Emscripten >LLVM bytecode >JavaScript >| This allows running C/C++ codebases in a browser for exampleGO TRANSLATOR>ACCESSDATE=11 JANUARY 2018, C (programming language) >Go (programming language)>Go Before the 1.5 release, the Go compiler was written in C. An automatic translator was developed to automatically convert the compiler codebase from C into Go.HTTPS://GOLANG.ORG/DOC/GO1.5>TITLE=GO 1.5 RELEASE NOTESAUTHOR=RUSS COX, 11 January 2018, Since Go 1.5, the "compiler and runtime are now implemented in Go and assembler, without C".Google Web Toolkit >Java (programming language)>Java program that uses a specific Application programming interface >JavaScript >| The Java code is a little bit constrained compared to normal Java code.PUBLISHER=Ocsigen >OCaml >| JavaScriptDOI=10.1007/978-3-642-21952-8_4 DATE= Java (programming language)>Java Eiffel (programming language) >| The resulting Eiffel code has classes and structures similar to the Java program but following Eiffel syntax and conventions.PUBLISHER=SE.INF.ETHZ.CH ACCESSDATE=2014-07-08, C (programming language) >Eiffel (programming language)>Eiffel The resulting Eiffel code has classes and structures that try to be as clean as possible. The tool is complete and relies on embedding the C and assembly code if it cannot translate it properly.DATE= Objective-C >Swift (programming language)> Swift Swiftify is an online source to source conversion tool from Objective-C into Swift. It assists developers who are migrating all or part of their iOS codebase into Swift. The conversion is aimed primarily at converting the syntax between Objective-C and Swift, and is helped because Apple took efforts to ensure compatibility between Swift and Objective-C runtimes.DATE= PHP >Java (programming language)>Java The Runtime Converter is an automatic tool which converts php source code into java source code. There is a Java runtime library for certain features of the PHP language, as well as the ability to call into the PHP binary itself using JNI for PHP standard library and extension function calls.

Transcompiler pipelines

A transcompiler pipeline is what results from recursive transcompiling. By stringing together multiple layers of tech, with a transcompile step between each layer, technology can be repeatedly transformed, effectively creating a distributed language independent specification.XSLT is a general purpose transform tool which can be used between many different technologies, to create such a derivative code pipeline.

See also

{{Div col|colwidth=20em}} {{div col end}}

References

{{Reflist|30em}}

- content above as imported from Wikipedia
- "source-to-source compiler" does not exist on GetWiki (yet)
- time: 2:24pm EST - Sat, Feb 23 2019
[ this remote article is provided by Wikipedia ]
LATEST EDITS [ see all ]
GETWIKI 09 MAY 2016
GETWIKI 18 OCT 2015
M.R.M. Parrott
Biographies
GETWIKI 20 AUG 2014
GETWIKI 19 AUG 2014
GETWIKI 18 AUG 2014
Wikinfo
Culture
CONNECT