Programming code tells the computer to do something, but what makes the code actually mean anything to the computer?

1.23K views

Programming code tells the computer to do something, but what makes the code actually mean anything to the computer?

In: Engineering

36 Answers

Anonymous 0 Comments

Finally one I’m qualified to answer.

Computers are made from electronic components. What these components are, has been changing as we progress in technology, but one thing they all have in common, is they only work on electricity (duh). But what this means is that our numbers and languages mean nothing to a computer, as we cannot convert them to electricity. But if we look at it, the electricity can also be mathematically modeled. This might sound complex, but it’s actually pretty intuitive, let’s say a switch, it will either be on, or be off. We can easily represent this as 1 for “on” and 0 for “off”. Technically we call it ‘high’ for 1 and ‘low’ for 0. This is because we don’t completely turn off the so called ‘switches’ of the electronic components inside the computer, but have two different levels of power, a high power (1) and a low power (0). Now what we want the computer to do is then just making a combination of these ‘components’ so that when we turn on a certain set of switches (which are our inputs) a certain set of bulbs will light up at the other side (which are our outputs) e.g if we have two inputs A and B and an output C, where A and B are the ‘switches’ and C is the ‘bulb’. We can create a circuit, where the bulb turns ON only when both A and B are ON. This means that C is 1 only when A and B are both 1. Thus we have successfully created what is called an **AND GATE.** There are many other such gates that we can use to create all different kinds of circuits to give a desired output for a certain set of input.

**What you read above was how MACHINE LANGUAGE works. The actual language that a computer understands.** In the early stages of the computer, this is exactly how we used to interact with computers, through 1s and 0s, but as we wanted to do more complex tasks with computers, it was tedious to type in 1s and 0s. So that’s when we decided to come up with short codes for all the long 1s and 0s, e.g we decided that ‘1000001’ means the letter A means , and ‘1000010’ means ‘B’ and so on.

Now the languages we use today, think of them as a pyramid. On the bottom is the machine language, and on the top are “high level languages” like Python and Java. The higher the language, the easier it is for us to understand. The lower the language, the easier it is for the computer to understand. So accordingly, we have different set of translators for different sets of languages depending on where they lie on the pyramid. For the highest level languages, the translators are equally complex, whereas for machine language, we don’t need a translator.

The rest is just a job of programmers creating this translator, called a ‘compiler’ or an ‘interpreter’ so that it translates the code we write to what we want it to mean in the corresponding machine language instruction

You are viewing 1 out of 36 answers, click here to view all answers.