A program written in high-level language is called as source code. To convert the source code into machine code, translators are needed. Show
A translator takes a program written in source language as input and converts it into a program in target language as output. It also detects and reports the error during translation. Roles of translator are: • Translating the high-level language program input into an equivalent machine language program. • Providing diagnostic messages wherever the programmer violates specification of the high-level language program. Different type of translatorsThe different types of translator are as follows: CompilerCompiler is a translator which is used to convert programs in high-level language to low-level language. It translates the entire program and also reports the errors in source program encountered during the translation.
InterpreterInterpreter is a translator which is used to convert programs in high-level language to low-level language. Interpreter translates line by line and reports the error once it encountered during the translation process. It directly executes the operations specified in the source program when the input is given by the user. It gives better error diagnostics than a compiler.
Differences between compiler and interpreter
AssemblerAssembler is a translator which is used to translate the assembly language code into machine language code.
Table of ContentsComputers are electronic devices that can only understand machine-level binary code (0/1 or on/off), and it is extremely difficult to understand and write a program in machine language, so developers use human-readable high level and assembly instructions. To bridge that gap, a translator is used, which converts high-level instructions to machine-level instructions (0 and 1). The translator is a programming language processor that converts a high-level or assembly language program to machine-understandable low-level machine language without sacrificing the code's functionality. Why Computer Language Translator?The computer only understands machine code. It is unable to understand any low, assembly, or high-level language. There must be a program to convert the source code into object code so that your computer can understand it. This is the job of the language translator. The programmer creates source code and then converts it to machine-readable format (object code) Purpose of Computer Language TranslatorThe main purpose of the translator is to make the machine understand the program written in a low/assembly/high-level language. Also Read: Top Real-world application written in C++ Types of Computer Language TranslatorThere are 3 types of computer language translators: They are:
CompilerThe compiler is a language translator program that converts code written in a human-readable language, such as high-level language, to a low-level computer language, such as assembly language, machine code, or object code, and then produces an executable program. In the process of creating an executable file, the compiler goes into various phases like Lexical Analysis, Syntax Analysis, Semantic Analysis, Intermediate Representation(IR) Generation,(Intermediate Representation)IR Optimization, Code Generation, and Optimization. Shortly, Some of the well-known compilers are:
Some common compiled languages are C++, C Characteristics of Compiler
Also Read: Computer / Laptop Ports in Detail
The interpreter converts high-level language to machine-level language, while the compiler accomplishes the same but in a different method. The Interpreter's source code is transformed into machine code at run time. The compiler, however, converts the code to machine code, i.e. an executable file, before the program starts. The interpreter program executes directly line by line by running the source code. So, it takes the source code, one line at a time, and translates it and runs it by the processor, then moves to the next line, translates it and runs it, and repeats until the program is finished. Some of the popular interpreted languages are Php, Python, Javascript, Ruby Characteristics of Interpreter
Advantage of InterpreterSome of the main advantages of interpreters are as follows:
Disadvantage of InterpreterSome of the main disadvantages of Interpreter are as follows:
Also Read: Different Parts of Motherboard AssemblerAssembler converts code written in assembly language into machine-level code. Assembly language contains machine opcode mnemonics so that assemblers translate from mnemonics to direct instruction in 1:1 relation. As we know the computer understands machine code only but programming is difficult for developers in machine language. So, low-level assembly language(ASM) is designed for a specific processor family that represents different symbolic code instructions. Characteristics of Assembler
Different Between Compiler, Interpreter, and Assembler
Also read: Can I delete photos after uploaded to Google Photos? Compiler vs Interpreter
Also Read: 19 Reason Why Windows OS is popular? Frequently Asked Questions 1 Is Assembly Language Portal? Ans: No, the assembly languages are not portable since they are tied to specific computer architecture.A program written and developed in one assembly language should be rewritten to run on another machine. 2 Which type of language is Assembly Language? Ans: Assembly Language (ASM) is a low-level programming language. 3 How is an interpreter slower than a compiler? Ans: Interpreting code is slower than compiled code. In compiler Case: When the program is successfully compiled, an object code file is created. This object code file is now executed. So, Unless we modify the source code, there is no need for recompilation. And directly execute from compiled code which seems to be faster because it is near to machine-level language. In interpreter Case: Every time we want to run a program, it is interpreted again and again. So, at runtime only code is translated to machine-level language. 4 What is the difference between compilation and execution? Ans: Compilation happens before execution in the compiling process. Source code gets compiled and produced execution file (like. dll and .exe ) file and this file gets executed at runtime. Compiler interacts with OS memory manager to perform compilation. Execution is done by the processor at the time of program execution. 5 What is the first stage of the compilation process? Ans: Lexical Analysis is the first stage of the compilation process. 6 How many parts of the compiler are there? Ans: Compiler has 3 important parts.
7 Is the linker part of the compiler? Ans: Some have distinct linkers and some do not. The linker is one of the important parts of the compiler which combines object code files and static file and produce an executable file. 8 What is Common Intermediate Language(CIL)? Ans: All the application that is targeting the .net framework is compiled first to an Intermediate language called CIL, which is a machine-independent language, and only at the run time do those intermediate languages gets converted to native machine code. The intermediate language in the Java environment is bytecode. 9) Is Java Compiled Language? Ans: There are two steps in the Java compilation process. At first source code is converted to byte code by the compiler and at runtime that byte code is verified by byte verifier and it decides it may compile and/or interpret the bytecode using the Java Interpreter/JIT Compiler. (source: StackOverflow) 10) Is a language translator a system software? Ans: System Software is those types of software designed to provide a platform for other software. This software provides an environment for the operating and programming where the users interact for creating application software. This includes Operating systems, Translator(Language processors), Simulators, Emulators, Utility software, etc. So, translators like compilers, translators, and interpreters are all system software. |