We know that computers need programs to work but how exactly do lines of code tell a box of wires to do anything? To add to that, how do lines of text end up being 1’s and 0’s? Is there magic that happens? Let us demystify that concept today and really understand how computers work.
In this article, I shall look at the various components in a computer that lead to translation of text to instructions, some gates and electricity. These concepts combined lead to interpretation of English to Binary. But first: a computer program is a set of instructions that performs a specific task when executed by a computer.
The first essential component in our breakdown of computers is the Central Processing Unit (CPU) which can be simply thought of as a collection of microelectronic components that execute instructions. These components are basically logical gates which I shall cover in a jiffy. These logical gates are in their billions in a single processor.
To understand logical gate, you need to embrace transistors. Transistors operate on the presence or lack thereof of electric current. When current passes through a transistor, it is considered to be on (1) and when there is no current passing through, it is considered to be off (0). From transistors, we are able to acquire logical gates that have the following operations; AND, OR, NOT and a combination of either those three. Those concepts basically form the CPU.
We now know the CPU is made up of transistors and circuitry. From here, there are standards that are already developed and coded. These standards have instructions that mean something specific. For example, we know the ‘+’ means addition and ‘-‘ means subtraction. There is a specific and exact meaning of those symbols. These codes, the CPU can read and execute based on the corresponding meaning (command).
That is not all though. You see, the computer only understands ones(1) and zeros(0) and English is nowhere near that. To achieve this translation, there is a programs that come into play – the Assembler. This program is pre-installed into the computer and translation to binary is already done. But these programs can also understand another language, High level language – or rather, human language. Before we get there, let us discover something interesting. We have 1’s and 0’s which we call Binary or Machine Language. The next level from machine code is Assembly Language. Now, assembly language almost always directly translates to machine code. From there, we have High Level Language which we, as humans can understand. So, how does the conversion work?
Say you have written a program. We know it cannot be executed as English, it has to be translated. How do you get from High Level Language to Machine Code? You use a compiler. This is a program that translates high level programming language into assembly language. From there, the assembler takes charge and translates assembly code into machine code. The instructions are run through the logical gates and instructions are followed. This of course, happens at very high speeds measured in billions of cycles per second. For instance, a processor rated 2 GHz executes 2,000,000,000 (billion that is) cycles per second. That seems fast but in modern computing, that is slow.
What we can see is that a series of conversions happen when an instruction is run and indeed, programs written in English end up in the CPU as 1’s and 0’s through the compiler and the assembler. To communicate with the human, the computer reverses the conversion from Machine Code. You can picture this as you using a translator to communicate to an audience who don’t speak your language. The translator must know both languages and must always do the translation for the audience to understand you and for you to understand the audience.
Now, you know.