Translator (computing): Difference between revisions

Content deleted Content added
m top: grammar
m Compilers: Wording
 
(38 intermediate revisions by 28 users not shown)
Line 1:
{{unreliable sources|date=March 2024}}
{{About|language translation of programming languages|translation of natural languages|Natural language processing|and|Machine translation}}
{{Program execution}}
{{Short description|Computer program that translates code from one programming language to another}}
{{Use dmy dates|date=February 2020|cs1-dates=y}}
{{Use list-defined references|date=January 2022}}
{{Program execution}}
A '''translator''' or '''programming language processor''' is a generic term that can refer to anything that [[Data conversion|converts]] code from one computer language into another.<ref name="Thornton_2017"/><ref name="Intel_1983_SH"/> A program written in a high-level language is called a source program. These include translations between [[high-level language|high-level]] and [[Source code|human-readable computer languages]] such as [[C++]] and [[Java (programming language)|Java]], intermediate-level languages such as [[Java bytecode]], [[low-level language]]s such as the [[assembly language]] and [[machine code]], and between similar levels of language on different [[computing platform]]s, as well as from any of the above to another.<ref name="Thornton_2017"/>
 
A '''translator''' or '''programming language processor''' is a [[computer program]] that converts the programming instructions written in human convenient form into machine language codes that the computers understand and process. It is a generic term that can refer to anythinga that[[compiler]], [[Dataassembler conversion(computing)|convertsassembler]], or [[interpreter (computing)|interpreter]]&mdash;anything that converts code from one computer language into another.<ref name="Thornton_2017MCT"/><ref name="Intel_1983_SH"/> A program written in a high-level language is called a source program. These include translations between [[high-level language|high-level]] and [[Source code|human-readable computer languages]] such as [[C++]] and [[Java (programming language)|Java]], intermediate-level languages such as [[Java bytecode]], [[low-level language]]s such as the [[assembly language]] and [[machine code]], and between similar levels of language on different [[computing platform]]s, as well as from any of the abovethese to anotherany other of these.<ref name="Thornton_2017MCT"/>
The term is also used for translators between software implementations and hardware implementations ([[ASIC]]s [[microchip]]s) of the same program, and from software descriptions of a microchip to the [[logic gate]]s needed to build it.{{Citation needed|date=July 2019}}
 
Software and hardware represent different levels of abstraction in computing. Software is typically written in high-level programming languages, which are easier for humans to understand and manipulate, while hardware implementations involve low-level descriptions of physical components and their interconnections. Translator computing facilitates the conversion between these abstraction levels.<ref>{{Cite web |last=Beaulieu |first=Adrien |date=2022 |title=A15. Front-End and Back-End Technologies: The Importance of Proficiency in Multiple Programming Languages |url=https://product.house/front-end-and-back-end-technologies-the-importance-of-proficiency-in-multiple-programming-languages/}}</ref> Overall, translator computing plays a crucial role in bridging the gap between software and hardware implementations, enabling developers to leverage the strengths of each platform and optimize performance, power efficiency, and other metrics according to the specific requirements of the application.<ref>{{Cite web |last=Pagadala |first=Santosh Kumar |date=2004 |title=Portable implementation of computer aided design environment for composite structures |url=https://researchrepository.wvu.edu/cgi/viewcontent.cgi?article=2455&context=etd}}</ref>
== Different types of translators ==
 
== Programming language processors ==
The 3 different types of translators are normally as follows:
The software development process is noticeably different depending on the type of translator used by a developer, this of course differs from translator to translator. Stages of the development process that are influenced by a translator include the initial programming stage, the [[debugging]] stage, and most notably the execution process. Factors that are affected during these stages include code performance, feedback speed for the debugging process, language features, and platform independence. Some of the more notable programming language processors used to translate code are [[Compiler|compilers]], [[Interpreter (computing)|interpreters]], and [[Assembly language|assemblers]].<ref name=":0">{{Cite web |date=2018-08-09 |title=Language Processors: Assembler, Compiler and Interpreter |url=https://www.geeksforgeeks.org/language-processors-assembler-compiler-and-interpreter/ |access-date=2024-03-15 |website=GeeksforGeeks |language=en-US}}</ref>
 
=== CompilerCompilers ===
Compiler software interacts with [[source code]] by converting it typically from a higher-level programming language into [[object code]] that can later be executed by the computer's [[central processing unit]] (CPU).<ref name=":1">{{Cite web |title=CSE 5317/4305: Design and Construction of Compilers |url=https://lambda.uta.edu/cse5317/notes/short.html |access-date=2024-03-15 |website=lambda.uta.edu}}</ref> The object code created by the compiler consists of [[Machine code|machine-readable code]] that the computer can process. This stage of the computing process is known as compilation. Utilizing a compiler leads to separation in the translation and execution process. After compilation, the new object code is saved separately from the source code resulting in the source code no longer being required for the execution process. With compiler programs, translation is a one-time process which results in efficient code that can be executed quickly any number of times.<ref name=":1" />
{{main|Compiler}}
A [[compiler]] is a translator used to convert [[high-level programming language]] to [[low-level programming language]]. It converts the whole [[Computer program|program]] in one session and reports [[Software bug|errors]] detected after the conversion. The compiler takes time to do its work as it translates high-level code to lower-level code all at once and then saves it to memory.
A compiler is [[Central processing unit|processor]]-dependent and [[Cross-platform software|platform-dependent]].
It has been addressed by alternate names as the following: special compiler, cross-compiler and, source-to-source compiler.<ref name="TCS_2018"/><ref name="Thornton_2017"/><ref name="Pasteur_2008"/>
 
There are clear benefits when translating high-level code with a compiler.<ref name=":2">{{Cite web |date=March 15, 2024 |title=Translator Types |url=https://adacomputerscience.org/concepts/trans_assembler_compiler_interpreter?examBoard=all&stage=all |access-date=March 15, 2024 |website=Ada Computer Science}}</ref>
=== Interpreter ===
{{main|Interpreter (computing)}}
The [[Interpreter (computing)|interpreter]] is similar to a compiler, as it is a translator used to convert [[high-level programming language]] to [[low-level programming language]]. The difference is that it converts the program one line of code at a time and reports errors when detected, while also doing the conversion.
An interpreter is faster than a compiler as it immediately executes the code upon reading the code.
It is often used as a [[debugging tool]] for [[software development]] as it can execute a single line of [[computer code|code]] at a time. An interpreter is also more portable than a compiler as it is [[Central processing unit|processor]]-independent, you can work between different [[Computer hardware|hardware]] [[Computer architecture|architectures]].<ref name="TCS_2018"/><ref name="Thornton_2017"/><ref name="Pasteur_2008"/>
 
* Compilation leads to faster run time when executing the program. Since code is translated before execution, its results are optimized and fast.
=== Assembler ===
* Compilers are more ideal when protecting code from [[plagiarism]] and preventing the use of source code from an unauthorized party.
{{main|Assembly language#Assembler}}
* Object code only needs to be created once when compiling source code.
An [[Assembler (computing)|assembler]] is a translator used to translate [[assembly language]] into [[machine language]]. It has the same function as a compiler for the assembly language but works like an interpreter. Assembly language is difficult to understand as it is a low-level programming language. An assembler translates a [[low-level language]], such as an assembly language to an even lower-level language, such as the [[machine code]].<ref name="TCS_2018"/><ref name="Thornton_2017"/>
 
There are clear disadvantages when translating high-level code with a compiler.<ref name=":2" />
== See also ==
[[File:Compiler scheme (en).svg|thumb|This image represents the translation process through a compiler.]]
 
* Object code produced during compilation is specific to a machine's [[instruction set architecture]] (ISA). This results in object code that is dependent on a specific type of machine in order to run.
* The debugging stage of the development process cannot start until the program is fully compiled. Errors are only viewable after compilation.
* Any source code that is modified must be fully recompiled to be executed again.
 
Some notable programming languages that utilize compilers include:<ref>{{Cite web |title=Compiled versus interpreted languages |url=https://www.ibm.com/docs/en/zos-basic-skills?topic=zos-compiled-versus-interpreted-languages |access-date=2024-03-15 |website=www.ibm.com |language=en-us}}</ref>
 
* [[C (programming language)|C]]
* [[C++]]
* [[COBOL]]
* [[Fortran]]
* [[PL/I]]
* [[Java (programming language)|Java]]
* [[Rexx|REXX]]
 
=== Interpreters ===
Interpreter programs function by interpreting high-level code into machine useable code while simultaneously executing the instructions line by line. Unlike compilers, interpreters do not need to compile the code prior to executing the instructions. The translation and execution process are done simultaneously and is interrupted in the event of an error in the program. The use of an interpreter allows developers to test and modify code in real-time. It makes the debugging process easier as well as aids in making more efficient code. Since the translation and execution process is done simultaneously, the execution time for interpreter programs is substantial.<ref name=":0" />
 
There are clear benefits when translating high-level code with an interpreter.
 
* Since object code is not created in the interpretation process, less memory is required for the code.<ref name=":0" />
* Interpreter languages do not create machine-specific code and can be executed on any type of machine.<ref name=":2" />
* The development and debugging process is typically quicker due to less complexity and it has more flexibility.<ref name=":2" />
 
There are clear disadvantages when translating high-level code with an interpreter.<ref name=":2" />
 
* Programs require that an interpreter is installed on the machine in order to run and interpret it.
* The execution time of the program is slower than a compiler.
 
Some notable programming languages that utilize interpreters include:<ref name=":0" />
 
* [[Python (programming language)|Python]]
* [[JavaScript]]
* [[Perl]]
* [[Ruby (programming language)|Ruby]]
 
=== InterpreterAssemblers ===
An assembler program functions by converting low-level assembly code into a conventional machine code that is readable by the CPU. The purpose of assembly language, like other coding languages, is to make the programming process more user-friendly than programming in machine language. Assembler languages utilize mnemonic devices and symbolic addresses to differentiate between opcode, operands, and specific memory addresses. Many of these components are not easily readable by humans and therefore mnemonics, symbols, and labels make the code decipherable. The assembler works by processing code one line at a time and then moves on to the next instruction. To eliminate issues that occur due to addressing locations, the translation process known as assembly is typically done in a two-pass process. The first pass of assembly is done in order to identify binary addresses that correspond to the symbolic names. This is essential in order to guide pass two which is the line-by-line translation into machine language.<ref name=":3">{{Cite book |last1=Patt |first1=Yale |title=Introduction to computing systems: From bits & gates to C/C++ & Beyond |last2=Patel |first2=Sanjay |publisher=McGraw-Hill |date=August 15, 2019 |isbn=978-1260150537 |edition=3rd |___location=New York, NY |pages=231–243}}</ref>
 
Commonly used assemblers include:
 
* [[X86 assembly language|x86 assembly languages]] (used in Intel and AMD processors)<ref name=":4">{{Cite journal |last=Stokoe |first=William |date=May 6, 2024 |title=sign language structure |url=https://www.lenovo.com/us/en/glossary/assembly-language/ |access-date=2024-03-15 |journal=Annual Review of Anthropology |volume=9 |pages=365–390 |doi=10.1146/annurev.an.09.100180.002053 |language=English|url-access=subscription }}</ref>
* [[ARM Assembly Language Programming|ARM assembly language]] (used in mobile devices)<ref name=":4" />
* [[MIPS architecture|MIPS]] assembly language (used in gaming consoles)<ref name=":4" />
* [[PowerPC]] assembly language<ref name=":4" />
* [[Little Computer 3|LC-3]] assembly language (used primarily in education to program the LC-3 computer) <ref name=":3" />
 
== See also ==
* [[Binary translator]]<!-- ([[Static binary translator]], [[Dynamic binary translator]]) --> (binary-to-binary, typically code)
* [[Assembly language translator]] (low-level source-to-source, code)
* [[Source-to-source translator]] (high-level source-to-source, code)
* [[Rewriter]] (source-to-source, typically code)
* [[Source-code formatter]] (source-to-source, typically code)
* [[File converter]] (binary-to-binary, typically data)
* [[Transcoder]] (binary-to-binary, data)
 
== References ==
{{Reflist|refs=
<ref name="Intel_1983_SH">{{cite book |title=Software Handbook |chapter=Translators And Utilities For Program Development |page=3-1 |date=1984 |orig-date=1983 |publisher=[[Intel Corporation]] |id=230786-001 |url=http://bitsavers.trailing-edge.com/components/intel/_dataBooks/230786-001_Intel_Software_Handbook_1984.pdf |access-date=2020-01-29 |url-status=live |archive-url=https://web.archive.org/web/20200129010534/http://bitsavers.trailing-edge.com/components/intel/_dataBooks/230786-001_Intel_Software_Handbook_1984.pdf |archive-date=2020-01-29}}</ref>
<ref name="TCS_2018MCT">{{cite web |title=Translators:What Purposeare compilers, Typestranslators, Examplesinterpreters, &and Advantagesassemblers? |date=20182017-0102-1117 |publisherauthor-first=TeachScott Computer|author-last=Thornton Science|work=MicrocontrollerTips |url=httpshttp://teachcomputersciencewww.microcontrollertips.com/compilers-translators-interpreters-assemblers-faq/ |access-date=20222020-0102-0902 |url-status=live |archive-url=https://web.archive.org/web/2022010922333320190719223609/https://teachcomputersciencewww.microcontrollertips.com/compilers-translators-interpreters-assemblers-faq/ |archive-date=20222019-0107-0919}}</ref>
<ref name="Thornton_2017">{{cite web |title=What are compilers, translators, interpreters, and assemblers? |date=2017-02-17 |author-first=Scott |author-last=Thornton |work=MicrocontrollerTips |url=http://www.microcontrollertips.com/compilers-translators-interpreters-assemblers-faq/ |access-date=2020-02-02 |url-status=live |archive-url=https://web.archive.org/web/20190719223609/https://www.microcontrollertips.com/compilers-translators-interpreters-assemblers-faq/ |archive-date=2019-07-19}}</ref>
<ref name="Pasteur_2008">{{cite book |author-first1=Katja |author-last1=Schuerer |author-first2=Catherine |author-last2=Letondal |author-first3=Eric |author-last3=Deveaud |date=2008-02-04 |orig-date=2003-01-06 |publisher=[[Pasteur Institute]] |title=Introduction to Programming using Python - Programming Course for Biologists at the Pasteur Institute |chapter=Chapter 5. Program execution, Section 5.2. Interpreter and Compiler |website=pasteur.fr |pages=37–40 |chapter-url=http://www.pasteur.fr/formation/infobio/python/ch05s02.html <!-- |url=http://www.pasteur.fr/formation/infobio/python/index.html -->|access-date=2015-01-07 |url-status=dead |archive-url=https://web.archive.org/web/20151111024459/http://www.pasteur.fr/formation/infobio/python/ch05s02.html |archive-date=2015-11-11}} [https://web.archive.org/web/20151124102155/http://www.pasteur.fr/formation/infobio/python/support.pdf]</ref>
}}
 
<!-- <ref name="Pasteur_2008">{{cite book |author-first1=Katja |author-last1=Schuerer |author-first2=Catherine |author-last2=Letondal |author-first3=Eric |author-last3=Deveaud |date=2008-02-04 |orig-date=2003-01-06 |publisher=[[Pasteur Institute]] |title=Introduction to Programming using Python - Programming Course for Biologists at the Pasteur Institute |chapter=Chapter 5. Program execution, Section 5.2. Interpreter and Compiler |website=pasteur.fr |pages=37–40 |chapter-url=http://www.pasteur.fr/formation/infobio/python/ch05s02.html <!-- |url=http://www.pasteur.fr/formation/infobio/python/index.html -->|access-date=2015-01-07 |url-status=dead |archive-url=https://web.archive.org/web/20151111024459/http://www.pasteur.fr/formation/infobio/python/ch05s02.html |archive-date=2015-11-11}} [https://web.archive.org/web/20151124102155/http://www.pasteur.fr/formation/infobio/python/support.pdf]</ref>-->
}}
== Further reading ==
* {{cite book |title=Assemblers, Compilers, and Program Translation |author-first=Peter |author-last=Calingaert |editor-first=Ellis |editor-last=Horowitz |editor-link=Ellis Horowitz |date=1979 |orig-dateyear=1978-11-05 |series=Computer software engineering series |publisher=[[Computer Science Press, Inc.]] |publication-place=Potomac, Maryland, USA |___location=[[University of North Carolina at Chapel Hill]] |edition=1st printing, 1st |isbn=0-914894-23-4 |issn=0888-2088 |lccn=78-21905 |url=https://books.google.com/books?id=x84mAAAAMAAJ |access-date=2020-03-20 |url-status=live |archive-url=https://web.archive.org/web/20200320183710/https://books.google.de/books?id=x84mAAAAMAAJ&redir_esc=y |archive-date=2020-03-20}} (2+xiv+270+6 pages)
* {{cite web |title=Why Hasn't AI Mastered Language Translation? |author-first=David |author-last=Pring-Mill |work=Singularity Hub |publisher=[[Singularity University]] |date=2018-03-04 |url=https://singularityhub.com/2018/03/04/why-hasnt-ai-mastered-language-translation/#sm.00000g1rmbl85mcrmqbgjyoco3zrf |access-date=2020-02-02 |url-status=live |archive-url=https://web.archive.org/web/20191229055424/https://singularityhub.com/2018/03/04/why-hasnt-ai-mastered-language-translation/#sm.00000g1rmbl85mcrmqbgjyoco3zrf |archive-date=2019-12-29}}
* {{cite web |title=Language processors |author-first=Stephen A. |author-last=Edwards |publisher=[[Columbia University]] |date=Fall 2013 |url=http://www1.cs.columbia.edu/~sedwards/classes/2013/w4115-fall/processors.pdf |access-date=2020-02-02 |url-status=live |archive-url=https://web.archive.org/web/20190624175913/http://www1.cs.columbia.edu/~sedwards/classes/2013/w4115-fall/processors.pdf |archive-date=2019-06-24}}
Line 51 ⟶ 93:
 
[[Category:Programming language implementation]]
 
{{software-type-stub}}