A computer doesn’t actually understand the phrase ‘Hello, world!’, and it doesn’t know how to display it on screen. It only understands on and off. So to actually run a command like print 'Hello, world!', it has to translate all the code in a program into a series of ons and offs that it can understand.
To do that, a number of things happen:
- The source code is translated into assembly language
- The assembly code is translated into machine language
- The machine language is directly executed as binary code.
Confused? Let’s go into a bit more detail
The coding language first has to translate its source code into assembly language, a super low-level language that uses 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).
The coding language then sends off the assembly code to the computer’s assembler, which converts it into the machine language that the computer can understand and execute directly as binary code.
But what does this all mean?
Isn’t it amazing to think that something as deceptively simple and primitive as binary code can create things as complex as what goes on inside a computer?
Your screen, operating system, photos, videos, the Internet, Facebook, your online bank account, and this website – all these things can be constructed from nothing but 1s and 0s. It’s a real symbol of human achievement.
Don’t worry if this process seems complicated and confusing – the whole reason that coding languages exist is to simplify it all for you!