Lesson 1 - Compiling terms

Humans and computers do not speak the same language. Computers use machine code while humans communicate using source code. Machine code instructions are in binary and is specific to the type of computer it is written for. In order to convert source code to machine code it must be translated using a translator. The most common translator is a compiler which will convert source code directly into machine code. The result is sometimes refered to as an executable (.exe file)

Source code - Human readable code. When a developer writes a program they will create source code. Code written in any language will always be known as source code. Below is an example of source code -


x = 5 
if x<10: 
   print "X is smaller than 10"
else:
   print "X is larger than 10" 
					
					

Machine code - Machine readable code. This is code which is run directly on the CPU. Machine code is in binary code. Each binary instruction is made up of a opcode and data. Assembly code is the human equivalent and is covered on the A2 part of the course.

Translator - This will convert source code into machine code. It is not a one to one mapping and a single line of source code could be converted into many lines of machine code. The compilation process is covered in detail in the A2 part of the course. There are different types of translators. Compiler is one of them.

Compiler - This is a piece of software which will translate source code directly into machine code. The code generated can be run on the CPU and is sometimes referred to as a executable.

Some programming languages are interpreted using an interpret rather than compiling. This means that each line of source code is read, translated and then executed immediately. This means that every time the code is executed it will be translated. These are referred to as interpreted languages. Javascript is an example of this.

Some languages are compiled into a intermediate language, known as byte code, and then interpreted through a virtual machine or VM. This is very common in modern programming languages. Python is an example of a compiled and then interpreted language. You can read this up in more detail by following the virtual machine link.

Interpreter - A translator which translates and executes each line of source code independently. A interpreted must be available in order to run the program.

Intermediate language - This is a machine independent form of machine code. It means that the code can be run on any host computer as long as they have a virtual machine. This makes code much more portable.

Virtual machine - A virtual computer which runs inside a host. This will provide all of the necessary resources needed to run intermediate code (byte code). A VM will act as an interpreter to the intermediate code. The use of a virtual machine tries to bring the best of both a compiler and an interpreter.