Topic 37.
Computer Language Translators
Computer Language Translator
Computers 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 Translator
The main purpose of the translator is to make the machine understand the program written in a low/assembly/high-level language.
Types of Computer Language Translators
1. Compiler
2. Interpreter
3. Assembler
1. Compiler
The 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.
Some of the well-known compilers are:
Borland Turbo C
Javac
GNU compiler
Xcode
Roslyn
Visual C#
CLISP
Oracle Fortran
2. Interpreter
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:
Php
Python
Javascript
Ruby
3. Assembler
Assembler 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.
Check yourself!