What is Programming (2): Do Modern Languages Still Use 0 and 1?

I would like to thank Ece Köseoğlu who suggested I write about this topic.
Hello dear readers! Welcome back to the second part of this series of articles where we learn what a programming language is. In part 1, you may remember that we learnt about microprocessors and why they only understand 0s and 1s; we then talked about how people write software that microprocessors can understand directly. In this second part, we’ll be learning about the more modern languages which are much more user friendly.
Section 3: So, do modern languages still use 0 and 1?
No! After a while, people started thinking that there has to be a better way to write code. Have you tried writing half a page of 0s and 1s just to print your name on the screen? Me neither! Probably not much fun… After a while, David Wheeler or Kathleen Booth (see: Appendix 1) invented the "assembly" language. While this language is harder to programme in comparison to modern languages, it is immensely important for both historical and modern reasons (as we will find out later).
Like machine code, instead of a single assembly language, every microprocessor vendor/model has a different assembly language. However, there are many similarities between these languages. Okay, before we examine the assembly language, we need to find out about how processors perform calculations. Processors place the results of computations into "memory boxes" called "registers". In simple terms, these boxes store results and allow for the processor to remember the results of previous computations - that's all.
Unlike machine code, instead of 0s and 1s, we use commands of 3-4 characters written in human languages now. For example, let's start by examining this machine code (the lines starting with a ";" are the explanatory comments I wrote):
; put the value 1 inside the register no. 0
; here, 11111111 denotes the register no. 0
0101 1 11111111
; Add 4 to the value stored in register no. 0
0011 0 101
; Move the value in register 0 to register 1
0101 11111110 11111111
Okay, let's write the same code in assembly:
; In this code, $0x1 = the number 1, $0x4 = the number 4
MOV $0x1, %0
ADD %0, $0x4
MOV %1, %0
ADD denotes the addition operation, and MOV denotes the moving operation. While still not super easy, compared to machine code, it's much cleaner and comprehensible.
Section 4: All processors can only understand 0s and 1s
Read the section name; if that's correct, how do processors understand assembly, which is not written with 0s and 1s? Let me explain with an example: you don't speak Finnish, but you need to communicate with someone who only speaks Finnish. How can you do this? You can of course use a translator. You speak English, and the translator translates it to Finnish. In the same way, computers have a "translator" (the actual term is "compiler") which can translate assembly language into machine code.
Section 5: Modern languages
Lastly, let's talk about modern languages (called "high level" languages), which are used today, and their connections to the concepts we have learnt about. Firstly, all the modern languages, assembly languages and machine code are, theoretically, equally powerful. This means that if you can do a computation in one, you can do it with all the others. The difference between them is that it is easier and more readable to write programmes in some of them (e.g., compare assembly and machine code) as well as some other differences which I will not mention here to keep this article short.
So, what do modern languages look like? What does code written in them look like? Let's look at this piece of code written in Python, my favourite language these days:
if 7 > 5:
y = 10
else:
y = 5
Briefly, the code is saying that if 7 is greater than 5 (7 > 5), then the value of the "y" box (actual term is a "variable") will be 10 (y = 10). However, if this is not true (else), then y will have a value of 5. To understand why code written in a modern language is much simpler, let's see what the same code written in assembly looks like (I haven't written assembly in a long time, so technical readers: please excuse my mistakes):
CMP $0x7, $0x5
JG TEN
MOV $0x5, %y
JMP EXIT
TEN: MOV $0x10, %y
EXIT:
For the sake of brevity, I will not explain the code, as there is no need. Someone with no technical knowledge can read a piece of code written in a modern language and more or less understand what's going on. However, the same code written in assembly language is complicated and hard to write. These reasons mean that more mistakes will happen when writing code, and also that it will take much longer. Because of that, modern languages were invented.
Lastly, let's go back to the idea of translating 0s and 1s mentioned in the previous section. Most of the time, modern languages do not get translated into 0s and 1s (but are always done so indirectly). Instead, there are a few popular options:
- Modern code is converted into assembly code, and assembly code is translated into machine code. The tool which does this kind of translation is called a "compiler". Two languages that (usually) work this way are C and Java.
- Modern code is not converted into some other language. Instead, a tool called an "interpreter" reads and understands the code and tells the computer what it needs to do - kind of like a middle-person.
As always, I hope I have been able to explain these concepts in a plain language which was fairly easy for those with no technical backgrounds to understand them.
Appendix 1: Who invented the assembly language?
Unfortunately, the sources I could find conflicted with each other. IEEE Computer Society (an institution highly respected in Computer Science), accepts that it was David Wheeler who invented the assembly language.[1] However, the Centre for Computing History accepts that it was Kathleen Booth who invented the assembly languages.[2]
References
[1] David Wheeler Biography. IEEE Computer Society.
[2] Kathleen Booth. Centre for Computing History.

