服务承诺
资金托管
原创保证
实力保障
24小时客服
使命必达
51Due提供Essay,Paper,Report,Assignment等学科作业的代写与辅导,同时涵盖Personal Statement,转学申请等留学文书代写。
51Due将让你达成学业目标
51Due将让你达成学业目标
51Due将让你达成学业目标
51Due将让你达成学业目标私人订制你的未来职场 世界名企,高端行业岗位等 在新的起点上实现更高水平的发展
积累工作经验
多元化文化交流
专业实操技能
建立人际资源圈Differences_Between_a_Compiler_and_Translator
2013-11-13 来源: 类别: 更多范文
Definition of a Translator
Language translators convert programming source code into language that the computer processor understands. Programming source code has various structures and commands, but computer processors only understand machine language. Different types of translations must occur to turn programming source code into machine language, which is made up of bits of binary data. The three major types of language translators are compilers, assemblers, and interpreters.
Definition of a Compiler
A compiler is a type of language translator. It is a set of instructions(Software) that translates (compiles) source code written in a high-level language (e.g., C/C++, COBOL, C++) into a set of machine-language consisting of a string of 0s and 1s instructions that can be understood by a computer's CPU. Compilers are very large programs, with error-checking and other abilities. Some compilers translate high-level language into an intermediate assembly language, which is then translated (assembled) into machine code by an assembly program or assembler. Assembly language is a symbolic, non binary format for instructions (human-readable version of machine language) that allows mnemonic names to be used for instructions and data; for example, the instruction to add the number 39321 to the contents of register D1 in the central processing unit might be written as ADD#39321, D1 in assembly language, as opposed to a string of 0's and 1's in machine language. Other compilers generate machine language directly.
A utility known as a "linker" then combines all required machine language modules into an executable program that can run in the computer.
The following is a conceptual example of source code being converted to machine language by the compiler:
Source Code Assembly Language Machine Language
IF COUNT=10 Compare A to B Compare 3477 2883
GOTO DONE If equal go to C If = go to 23883
ELSE Go to D Go to 23343
GOTO AGAIN
ENDIF
Actual Machine Code (simulated)
10010101001010001010100
10101010010101001001010
10100101010001010010010
10 differences between compilers and translators
1. A translator usually has to generate structured, maintainable code in the target language which makes use of idioms in the target language where possible.
A compiler can generate any code it likes so far as it is syntactically valid for the target language.
2. A compiler has to cope with any valid syntax in the source language,and generate semantically equivalent code in the target language.
A translator usually has a fixed body of code that it is required to translate.
3. A compiler usually has to do optimisation. A translator can rely on the compiler for the target language to do optimisation: in fact, it should not do optimisations which affect readability of the code.
4. A compiler is translating from a higher level language to a lower level language (or to a low level subset of the target language). A translator is usually translating from a high level language to another high level language or from a low level language to a high level language. For example, translating from assembler language to C or COBOL
5. A translator presumes the code is correctly formatted and would compile if passed to a compiler.Compilers syntactically scan code to find syntax errors and in some cases correct them.
6. A translator produces only output for another compiler, a compiler (usually) generates object files and/or executables. (Some actual compilers generate source for another language or assembly.)
7. A translator makes certain assumptions about the code being presented to it, that it is a complete or reasonably complete piece of code. A compiler will check and (usually) complain if you hand it a fragment of a program.
8. Translators convert programming source code into language that the computer processor understands.
A compiler is a type of language translator.
9. Compilers syntactically scan code to find syntax errors before compiling.
A translator translates the code and passes it to the compiler to compile.
10. A compiler can generate any code once it is syntactically valid for the target language.
A translator presumes the code is syntactically valid

