3.How does computer understand us?

Analogy 3.1
We saw the analogy in the previous chapter that Sam’s mother gave in the instructions to do the shopping in their mother tongue.(say they talk in English). What if Sam’s mother had to give these instructions of shopping to another guy next door, Shushil because Sam is unavailable. The problem here is Sam’s mother knows only English and Shushil knows only Hindi. So the set on instruction given by Sam’s mother will not be understood by Shushil although he is capable of doing that work if instructed in Hindi.
Then, how can Sam’s mother achieve the task of getting task done by Shushil?
Well, she can ask Sam to intervene or help who know both English and Hindi

  • Sam’s mother will submit the instructions in English,
  • Sam will translate those in Hindi.
  • Shushil receives the instruction in Hindi and does the work completely.
    ——Analogy ends——

Similar is the situation with computer As human, we will submit the instructions in the language/format which we understand unfortunately computer’s CPU does not under stand that language. Now,you will ask if computer does not understand English. Then what does it understand?
The answer is binary language. Just like English is a language composed of 26 alphabets 10 number digit(0-9) & symbols(you see on keyboard + you don’t see on keyboard ), binary language is composed of only two numbers 0&10.Nothing more than this.
No alphabet,no symbol, nothing.
Hence, whether you want your computer to add two number or you want your computer to add two numbers or you want your computer to play game or you want to data online, in any of these cases,instructions has to reach to CPU in the combination of 0s and 1s. So you can imagine instructions going to CPU some thing like this.
Instruction 1: 0001 1111 1000
Instruction 2: 0100 1000 1110 001



& so on.


Not only CPU, these memories (whether primary or secondary) store our data in binary format only.Isn’t it surprising that you favorite song is nothing but stored as 1111 0010 1011 1000 is your hard disk (secondary memory) just an example or your primary memory.

Now you may ask why does computers CPU understand only binary? Why can’t it understand our language?
Well it’s by design since the beginning of the time when computer where manufactured when human began understanding transistors and circuit, binary system also from there where 0 was considered switch off state and 1 was considered switch on state (where current is flowing through the circuit) after all computer is an electronic device first like any other electronic device like music system,amplifier,fridge etc
So, as human tarted developing into science understanding some elements like silicon he developed understanding on how this element can be a basic building block to create a device which can do calculation. As a result calculations were developed with consist of silicon.Human developed transistors by using silicon. There transistors had two States 1) when electric current passes through it it is one state and we can considered it as 1
2) when electric current does not pass through it it is considered as the second state we considered it as 0
There is no 3rd state. These two state enabled human to do calculations like arithmetic operation.

Millions of transistorswere integrated in a unit called Integrated Circuit (IC). Millions of such ICs are packed in the unit called microprocessor chip (this is only CPU).Hence the fundamental design of electronics is based on binary. Currently, we can’t incorporate our language into it since we will have to create that many states as there are alphabets.We will not discuss ICs, transistors etc in more detail as it is beyond the scope of our programming study. That is taught in detail in Electronics Engineering

Let’s know about these mechanism:

Compiler — It is the software installed on the computer which translates human-written program into machine language.

High Level Language — The English-like language format which we use to write instructionfor computer is called high-level language. Programming languages like Java, C, C++, Python, COBOL and all high level language.

The developers of these high level language have defined proper syntax & rules which we must follow while creating a program. It is done so that the compiler does not get “Talli” from China programme & “Fall” from Brazil programme to translate.

The compiler is so programmed such that when it receives “Talli” it will send 11001100 (for an example) to CPU. If you give an instruction say “Fall”, compiler will not translate it to machine language. Instead it will report error.

So, you wrote 10 lines of program in high-level language (think Java, since you are going to study Java afterwards). Obviously all these 10 lines of instruction have to be converted into machine language for CPU to understand and execute those 10 instructions. So, what are the ways we can translate those lines into machine language?

Way 1: Translate all the 10 lines into machine language first, & then all together, so store it permanently somewhere & then use the translated 10 lines as many times as you want. You don’t need to store your file containing the 10 lines of code program in high level language

You can delete it. The mechanism in compiler which does the translation this way is called compilation & the sophisticated software running behind our eyes is called Compiler.

ANALOGY 3.2 — Sam’s mother wrote all the instructions of shopping in English on a paper. & Sam translated all these instructions into Hindi on another paper, & hands over the paper to Sushil. Now, it does not matter whether the paper written by Sam’s mother is existent or thrown in the garbage as long as the paper written in Hindi is with Sushil. He can use those instructions for shopping not only one day but many days.

Example — Some egs. of compiler are:
GCC — which trans compiles (translates) C++
Javac — which compiles Java (high level language)

ANALOGY 3.2 — It is also worthwhile to note that Sam is not a dumb guy. While translating, if he finds any word written is not clear, He will interrupt his mother to rewrite it.

Way 2 — Translate each line in the instructions (program) into machine language one by one & execute translated line one by one.

flow chart 3.1

The software responsible for doing this way is called interpreter.

At any line, if an issue is encountered then the process is terminated & the process begins again.

Example — Programming languages like Python, Ruby & Javascript use interpreter.

ANALOGY 3.3 — Have you seen Bollywood movie Lagaan? How does Elizabeth talk to villagers? She takes the help of Ram Singh. She speaks one line in English. Ram Singh translates it to Hindi for villagers. Then Elizabeth goes on speaking second line & so the process continues. We can somewhat relate this analogy with interpreter. Sam is on phone call with Sushil while Sushil goes to the market. Sam’s mother gives some instructions to Sam. Sam instantaneously translates it to Sushil over phone.

What differences do you see between these two? What are the advantages & disadvantages of both? Put your thoughts in comment.

So now our understanding of computer system is something like this —

flow chart 3.1.2

I have labelled above parts as hardware & software for better understanding. The one labelled as hardware is what you can actually see & touch when your computer is screwed open in computer repair shop. Compiler/Interpreter Software is the one you can’t see or touch.

ASSEMBLER — Apart from interpreter and compiler, there is a third software which we come across is assembler. An assembler converts low-level language into machine language for CPU to understand. You might be wondering what is low-level language since you are aware of high-level language so far.

Low level language (also called assembly language) is neither the language of binary which computer’s CPU can understand & execute nor is it English-like that a human can easily understand.

You will ask why assembly language? Well, assembly languages are far better of high-level language & were used by programmers to write instructions before high-level language pitched in.

Assembly language are more close to heart of CPU, because the code written in assembly language for CPU brand Intel will not be same as written for AMD. Assembly language is specific to machine.

Assembly language is not that popularly used as high-level language, however it still has no replacement when it comes to:

  • manipulating hardware
  • addressing critical issues concerning performance because it is more clear to CPU.

Compiler तो रहे दो CPU high-level language को इस रत अगर है।

Even today many compilers translate the high-level language code into assembly language & then assembler takes the job of translating the assembly code to machine code (binary).

Eg. Intel

mov eax, [ebx]
mov eax, [ebx+3]

AT&T

movl (%ebx), %eax
movl 3(%ebx), %eax

Previous Article
Next Article