This was a piece I had originally written for the Turkish edition of Tabella, but since it proved to be popular, I wanted to translate it for the first issue of Tabella’s English edition. It is intended for a non-technical audience to improve their general knowledge.

Section 1: What is programming?

Let’s first start with this question: what is programming? To give a simple definition, it is telling the hardware of a computer what it should do. For example, telling a computer processor to compute something, to store some data in memory, to light up some pixels on the screen to show a picture or to tell a factory robot how to move its arms to assemble; all these can be accomplished by programming a computer. Based on this definition, we can define a programming language as an interface that a human can use to communicate with a computer to make it do something useful. As an example, a simple expression such as “move your arm 1 cm left” might be a part of a language which is used for programming a robot. Now that I have given you a definition, is the article over? Not yet, keep reading!

Section 2: What are the 0’s and 1’s then?

In this code language, different combinations of 0’s and 1’s, also called “machine code”, represent different commands that we want the processor to execute. For example, if “1100” represents addition, then “1100 0 1” may represent addition of 0 and 1. I said “may” because “machine code” is actually not just one language. In fact, every different processor brand (e.g. Intel and its rival AMD) or model may have a different machine code language using different combinations of 0’s and 1’s; however, since we will not be learning about specific machine code commands in this article, there is no point in focusing on this detail.

Now, let’s assume that the only way to talk to a computer is by using 0’s and 1’s, because when the first digital computers were invented, this very much was the case. I am sure you have many questions, but let’s start with the most important: why did they have to use 0 and 1?

This has to do with the electronics of a computer (I promise, this will not get too technical). 0 represents the lack of electric current, while 1 represents the presence of it. So, how do I make computations using currents? To understand this, we first need to understand arguably the most important invention of the 20th century: the transistor. We can think of these devices (which are usually made from silicon, from which the name of the Silicon Valley is derived) as shown in the diagram below:

In this diagram, A, B, and C represent electric cables while the circle in the middle is the transistor which connects all three cables together. In its normal state, the transistor does not let electric current carried by A to reach B; therefore, at the very start, B has no current, or having the value of “0”, regardless of whether or not A has it. Now, when we supply current to the cable C (thus making its value “1”), the transistor starts allowing the current from A to reach B.

If I have been able to explain things well and you are still with me, let us examine a device which is made up of multiple transistors: an Exclusive OR (XOR) logic gate:

As we have seen before, A, B, and C are electric cables in this diagram. However, this device works slightly differently; this time, for there to be a current in B, you need either A or C to have an electric current (but not both; so B has no current if both A and C have it). To understand what I mean, have a look at the table below:

 

































Input Output
A C B
0 0 0
1 1 0
0 1 1
1 0 1

 

For example, take the first row of the table; if A is 0 (i.e. it has no electric current) and C is 0 at the same time, then B will also be 0.

If we think of this device as a primitive “computer”, then the entire machine code language it can “understand” is what is in the table above. For example, if the code input is “00” (i.e. A is 0, C is 0), then the “computer” will give us the output “0”. This, by itself, is a valid computation: if input is this, then output that. But what useful things can we do with this primitive computer? Addition!

It is hard to believe at first, but let me explain: The table says, 00 ⇒ 0. In addition, 0 + 0 = 0. Also, the table says 10 ⇒ 1, and 1 + 0 = 1. This follows the rules of addition as well. Now also consider 11 ⇒ 0. However, 1 + 1 = 0 is not correct. What is going on? Us humans count in a 10-based system, so for us, 1 + 1 = 2. However, computers use a “binary” system which only uses 0 and 1 (so 2 does not exist and 1 + 1 is actually not 2). In this system:

 




























Number in 10-based system Number in binary system
0 0
1 1
2 10
3 11
4 100

 

I want to keep the article short, so I will not go into the maths behind why this is so; for now, assume that the above table is how things work.

Now let’s go back to the previous problem where the computer claims 1 + 1 = 0. The thing is, the computer only gives us the first digit of the actual answer. So, in binary, we expect 1 + 1 = 10, but the computer only gives us the rightmost digit of 0.

By connecting these primitive devices, you can achieve increasingly more complex computations and eventually arrive at the “modern computer”.

In my next article, I will be talking about more modern programming languages. I hope this article has been useful and simple enough for our non-technical readers.

Photo: Chris Ried, Unsplash.