How does the Computer Understand Programming Languages?

Junius Sim
4 min readFeb 8, 2018

--

One fine day when you are happily programming the computer to do sophisticated things, you might suddenly wonder:

How does the computer understand the language that i’m typing on my keyboard or even the binary language that my compiler spits out? What is this magic that allows computers to understand the language on my screen or the binary language even?

To answer this question, we really have to start to understand what a computer is. For the longest time, a computer was to me what you see in the image below.

Computer = Monitor + Keyboard + Mouse + Case (what?)

And this conceptual model of what a computer is works pretty damn well if you only play games or surf the net. It actually also works pretty well if you are a new programmer.

What’s wrong with this model?

This model of what a computer is fools us into thinking that the computer understands what we are typing through the keyboard. It gives us the impression that the computer can read what we see on the screen. Of course, we know that isn’t the case in reality, but it really gives us little clues about that question in our head and might throw some people off.

So what is a computer then?

A computer is what is inside that case, at least for the purpose of answering this question. The reality is that there are a shit ton of electrical components inside that case. These electrical components reflect a certain state of the computer and what we see on our display is merely a reflection of that state. When we type something on our keyboard, we are actually modifying the state of these electrical components. The display is built in such a way that it is able to read this new state and update accordingly.

Looking at early computer models would help us better understand the underlying state of a a computer and understand what typing does to the underlying state of a computer.

A beautiful computer.

Early computers had rows of toggle switches which were used to set the values of bits in main memory. You could program these computers by entering the bits of each machine instruction from the front panel switches. A light above each switch showed whether it was on or off (1 or 0). Modern computers have more convenient methods for moving bit patterns into memory. Did I hear someone say that they used to make things better?

The computer cannot understand the programs or language the way a human does.

  1. When we type a Javascript program into the computer, it gets stored somewhere inside the case (in RAM or our Hard Drive) in a binary electrical format.
  2. Some cool editor software is able to understand this electrical format and will continue to show on our screen a Javascript program.
  3. When we execute this program of ours, the binary electrical representation of this Javascript program gets reduced further into a different series of binary electrical circuits AKA machine language that the hardware can understand and work with.
  4. Just to be clear, we might still think this machine language refers to the series of 1010101010 characters that we see on the screen. That is not what the machine understands. The 1010101010 characters we see on the screen is again merely a reflection of the electrical switches underneath it all.
  5. The CPU (a series of electrical hardware components) is built to take in each line of binary electrical signals (ML instructions) and modify its electrical state accordingly.
  6. What we then see on our screen as a result of that program execution is again merely a reflection of this new electrical hardware state.

I hope i managed to adequately address this question. I had this question in my head for the longest time and a few months ago, something spurred me to take the first steps to answer this question. I picked up a few books and signed up for a class on Computer Architecture.

P.S I had my first class yesterday so i plan to update this article as my knowledge in this area improves. In the meantime, feel free to check out the books / courses below to find out more yourself.

But How Do it Know http://www.buthowdoitknow.com/index.html

The Elements of Computing Systems (Nand2Tetris) http://www.nand2tetris.org/

--

--

Junius Sim

I share my thoughts on everyday life and hope it makes a positive impact to people who need them.