How does programming language work?


How does programming language work?

How does programming language work?


Introduction 

Since we started learning about the programming we have been told that computer only understands the sequence of 0 and 1. It doesn’t understand python, javascript, PHP, C++, C, or any other programming language directly.this is true but But still, several questions remain unanswered such as,

Why do computers only understand 0  and 1?

How our computer understands the different numbers, text, images, videos.?

Let’s try to understand this one by one.


How our computer works?

    One of the basic things we need to know before we jump to other things. Our computer is made out of registers which acts like switches and basically controls the flow of electrons which is physics. Transistor only accepts two values either 0 and 1 or true and false. the single transistor is not useful but our computer uses millions of transistors ( approx 290 million transistors ) and with the help of a connected transistor our computer able to make logic out of it. If the switch is open that means the current is not flowing it considered as 0 and when the switch is closed that means the current can flow from the transistor is considered as 1. Here we got the answer to our first question of why the computer uses binary format.it is because transistors which we use in our circuit understand only two values and we need transistors to complete circuit or logic.

     we have a variety of data such as music, videos, image, text, number, etc. so how our computer converts such a different variety of data in just 0 or 1.this concept itself sounds crazy right imagin videos you are watching, images you are storing everything is just sequence of 0 and 1. let's see how computer able to do this conversion.

Number to binary

Divide the number by 2.

Get the integer quotient for the next iteration.

Get the remainder for the binary digit.

Repeat the steps until the quotient is equal to 0.


Text to binary

To convert text to binary we use the ASCII technique with this technique numbers given to each alphabet such as A=65 B=66 etc. text phrase gets convert into letters and letters get convert into numbers. this is how our computer differentiates different letters.

Example: A =65 = 01000001 in binary this is how our computer.

Image to binary

Our image is nothing but data in pixel format each pixel color is a combination of primary colors i.e RGB which we can write in 0-255 format i.e RGB color format which is again a number we have already seen how to convert number to binary so now our image is also got converted into binary.

Video to binary

Video is a combination of frames it’s the same as animations i.e 1 second of video holds 30 frames i.e 30 images. If video is in 60fps then there will be 60 images in 1 second of video we know that how images get to convert to binary in the same way each frame of our video gets convert to binary.

        Up to this point, we saw how different type of data gets coveted into binary format, now we need to know how we can convert our normal data into binary data. In our program, we write some logic in text format and our compiler or interpreter does the job of converting our program to binary this is how the whole process works. 

There will different compilers with different architecture each of those doing their best to optimize the conversion process, reuse the data, and things like that. 

We also have different programming languages each of the programming languages is different and created to solve different types of problems. So the choice of a programming language depends on which type of problem you are trying to solve.


conclusion

Here we have learned how our programming language works and how our computer understands it on a low level.


Post a Comment

0 Comments