Transcompiler
Encyclopedia
A transcompiler is a special compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

 that translates the source code
Source code
In computer science, source code is text written using the format and syntax of the programming language that it is being written in. Such a language is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source...

 of a programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 into the source code of another programming language, e.g. from Pascal to C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

.

One of the earliest programs of this kind was Digital Research
Digital Research
Digital Research, Inc. was the company created by Dr. Gary Kildall to market and develop his CP/M operating system and related products. It was the first large software company in the microcomputer world...

's XLT86 in 1981, a program written by Gary Kildall
Gary Kildall
Gary Arlen Kildall was an American computer scientist and microcomputer entrepreneur who created the CP/M operating system and founded Digital Research, Inc....

, which translated .ASM source code for the Intel 8080
Intel 8080
The Intel 8080 was the second 8-bit microprocessor designed and manufactured by Intel and was released in April 1974. It was an extended and enhanced variant of the earlier 8008 design, although without binary compatibility...

 processor into .A86 source code for the Intel 8086
Intel 8086
The 8086 is a 16-bit microprocessor chip designed by Intel between early 1976 and mid-1978, when it was released. The 8086 gave rise to the x86 architecture of Intel's future processors...

. 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
CP/M-86
CP/M-86 was a version of the CP/M operating system that Digital Research made for the Intel 8086 and Intel 8088. The commands are those of CP/M-80. Executable files used the relocatable .CMD file format...

 and MP/M-86 platforms automatically. XLAT86 itself was written in PL/I-80
PL/I
PL/I is a procedural, imperative computer programming language designed for scientific, engineering, business and systems programming applications...

 and was available for CP/M-80 platforms as well as for DEC VMS (for VAX 11/750 or 11/780).

Programming language implementation

The first implementations of some programming languages started as transcompilers, and the default implementation for some of those languages are still transcompilers:
  • C++
    C++
    C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

    , transcompiling to C with the cfront
    Cfront
    Cfront was the original compiler for C++ from around 1983, which converted C++ to C; developed by Bjarne Stroustrup. The preprocessor did not understand all of the language and much of the code was written via translations. Cfront had a complete parser, built symbol tables, and built a tree for...

     transcompiler
  • Eiffel
    Eiffel (programming language)
    Eiffel is an ISO-standardized, object-oriented programming language designed by Bertrand Meyer and Eiffel Software. The design of the language is closely connected with the Eiffel programming method...

    , transcompiling to C
  • Lisaac
    Lisaac
    Lisaac is a compiled object-oriented programming language based on prototype concepts, with system programming facilities and design by contract....

    , transcompiling to C
  • Vala
    Vala (programming language)
    Vala is a programming language created with the goal of bringing modern language features to C, with no added runtime needs and with little overhead, by targeting the GObject object system. It is being developed by Jürg Billeter and Raffaele Sandrini. The syntax borrows heavily from C#...

     transcompiling to C
  • CoffeeScript
    CoffeeScript
    CoffeeScript is a programming language that transcompiles to JavaScript. The language adds syntactic sugar inspired by Ruby, Python and Haskell to enhance JavaScript's brevity and readability, as well as adding more sophisticated features like array comprehension and pattern matching...

    , transcompiling to JavaScript
    JavaScript
    JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

  • haXe
    HaXe
    haXe is a versatile open-source high-level multiplatform programming language described on its website as a "universal language".It can produce:* Flash applications and games* Multi-platform client-side web applications* Apache CGI web applications...

    , transcompiling to JavaScript
    JavaScript
    JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

    , PHP
    PHP
    PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

    , C++
    C++
    C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

    . Also compiling to bytecode such as ActionScript
    ActionScript
    ActionScript is an object-oriented language originally developed by Macromedia Inc. . It is a dialect of ECMAScript , and is used primarily for the development of websites and software targeting the Adobe Flash Player platform, used on Web pages in the form of...

     bytecode.
  • Dart
    Dart (programming language)
    Dart is a Web programming language developed by Google. It was unveiled at the in Aarhus, 2011 October 10-12. The goal of Dart is "ultimately to replace JavaScript as the lingua franca of web development on the open web platform."- Reason for a new language :Dart is intended to solve JavaScript's...

    , transcompiling to JavaScript
    JavaScript
    JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

  • Mirah
    Mirah (programming language)
    Mirah is a programming language based on Ruby syntax, local type inference, hybrid static/dynamic type system, and a pluggable compiler toolchain...

    , transcompiling to Java
    Java
    Java is an island of Indonesia. With a population of 135 million , it is the world's most populous island, and one of the most densely populated regions in the world. It is home to 60% of Indonesia's population. The Indonesian capital city, Jakarta, is in west Java...

  • Efene, transcompiling to Erlang
    Erlang
    Erlang may refer to:* Agner Krarup Erlang , a mathematician and engineer after whom several concepts are named** Erlang , a unit to measure traffic in telecommunications or other domains...

  • Xtend, transcompiling to Java
    Java
    Java is an island of Indonesia. With a population of 135 million , it is the world's most populous island, and one of the most densely populated regions in the world. It is home to 60% of Indonesia's population. The Indonesian capital city, Jakarta, is in west Java...


Porting a code base

When developers want to use a different language while keeping most of a code base, it might be better to use a transcompiler compared to rewriting the whole software by hand. In this case, the code often needs manual correction because the automated translation does not work in all cases.

For example, the 2to3 script can turn Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

2 programs into Python 3 programs. Manual corrections are often needed after.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK