Computer Languages and Language Translators
A brief introduction to Computer Languages and translators.
What Will You Learn?
In this article you will learn:
- Introduction to Computer Languages
- Different types of Computer Languages
- Translator
What is Computer Language?
Computer language is a way to communicate with a computer. Computer language consists of a set of instructions and rules.
Why we Need a Language?
let’s take an analogy if 2 persons want to communicate with each other, what will be the first requirement? both can speak (any language)
Same as if a person wants to talk with a computer, s/he need a language which the computer can understand.
Different Type of Languages
Computer Languages are divided into two categories.
- High-Level Languages
- LowLevel Languages
1. High-Level Languages
High-level languages are closer to Human language and humans can understand and interpret these languages easily. A computer cannot understand High-level language program directly. Python, Java, C#, C++, C, COBOL, SWIFT, JavaScript, Php, R are some examples of high-level languages.
Python Code to Add Two Numbers
a=10
b=20
sum=a+b
print(sum)
Note: the above example is easy to understand, that we have two variables a and b, and the sum variable stores the result of a+b and print() function is used to print result on the screen.
2. Low-Level Languages
The type of language, a computer can understand easily and for humans difficult to understand is called low-level language. Assembly language and Machine language are examples of a low-level language.
Assembly Language program Example
.model small
.data
opr1 dw 1234h
opr2 dw 0002h
result dw 01 dup(?),\'$\'
.code
mov ax,@data
mov ds,ax
mov ax,opr1
mov bx,opr2
clc
add ax,bx
mov di,offset result
mov [di], ax
mov ah,09h
mov dx,offset result
int 21h
mov ah,4ch
int 21h
end
Note: Above example is written in Assembly language and it is difficult to understand with respect to writing code in a high-level language.
Translator
let’s take analogy if two persons are talking in different languages and they have no knowledge about other’s language then to communicate in a better way they need a translator which knows both of languages and translate one’s language to other’s language.
The computer cannot understand High-Level Language code directly, so we need a translator.
A translator translates high-level language code to machine understandable code. For example, we have written code in python language, the translator translates it into a low-level language. which can be assembly language or machine language code. Ultimately convert into Machine Language.
Types of Translators
- Compiler
- Interpreter
- Assembler
1. Compiler
The compiler is a type of language translator that translates a High-level language program to a low-level language as a whole. Errors are displayed after the whole compilation of the program. It works fast.
2. Interpreter
Type of language translator which translates High-level code line by line. If an error found in any line then it stops the execution of a program. It works slowly.
3. Assembler
An assembler translates assembly language code to Machine language code.
Note: Machine Language is actually a Binary Language(0’s and 1’s ), all types of data stores in computer memory as a combination of 0’s and 1’s.
For Example, the value of 9 in computer memory is 1001
Conclusion
In this article, we have discussed Computer languages and translators. We need a computer language to communicate with the computer and because low-level language is difficult to understand, so we write out the program in a high-level language and the translator translates it into machine understandable program.
your Question and suggestions are more than welcome!