Written in Code

Kane S
3 min readOct 24, 2019

--

Most people you’ve met, regardless of their age or occupation, have seen a few lines of code. Whether it’s one of those movies where the bad guy is attacking and they have some tech whizz slamming away at a keyboard like this guy…

…or maybe you’re like me and you’ve got a friend or relative who you’ve seen working on a project. It can all still look very complicated and stressy and depending on the language they’re using, well, sometimes it’s best just not to look.

All that being said you don't need to have level 20 intelligence to understand what’s going on under the hood when those lines of code are executed. The short answer is pretty much what you’d expect: that code is telling the computer what it wants the computer to do by turning those lines of code into a language the computer can understand (binary code). But of course, that’s not what this blog is for, so here’s the long answer.

A computer can only really understand two distinct types of data: on and off. The way this on or off is conveyed is through a thing called a transistor (a small device that regulates current or voltage flow). Absolutely everything and anything you see on a computer is some combination of these transistors turned on (1) and some of them turned off (0). These Ones and Zeros are what we know as binary code

Okay so cool, we go from this

to this

Well, we’ve gotta understand one more thing: the difference between a high level and low-level programming language. To keep it really simple, most of the programming languages you see often are high-level languages (ruby, python, javascript). They’re a little closer to human language. A low-level language is a bit closer to the binary that our computer understands. This is where our journey of understanding takes us next.

That program you wrote in your high-level language is now converted into Assembly Language. Assembly Language is a super low-level programming language that uses a specific group of words and numbers to represent binary patterns. Depending on the language, this may be done with an interpreter (where the program is translated line-by-line), or with a compiler (where the program is translated as a whole).

We’re almost there! The assembly code needs to be broken down just a little bit more. This occurs in an assembler, where our assembly code is then broken down into what is called Machine Code. And there it is! we’re pretty much there! Machine code is a set of instructions that can be directly executed by a computer’s CPU (Central Processing Unit). Each instruction in Machine Code causes the computer to do a very specific task, like load or store.

So what’s the link? how do we get from machine code to binary? Well, we mentioned that machine code is a set of instructions, and quite simply put, the computer understands these instructions as a sequence of binary values. Ones and zeros, That’s all it is!

Hopefully, after reading this you have at least a little more understanding of what’s going on when that code is run!

--

--