The Lifecycle of a Program

As we have learned, a computer’s CPU can only understand and execute machine code instructions. However, programmers seldom write machine code. Instead, they usually make use of high-level languages like C++ and Python to write code, which is then translated to machine code by the CPU. Hence, a program written in a high-level language undergoes various phases throughout its lifecycle. However, the translation steps vary for compiled languagesCompiled languages are programming languages in which code (written by the programmer) is translated into machine code, and the corresponding machine code is saved in a separate file. (e.g., C++) interpreted languagesInterpreted languages are programming languages in which code (written by the programmer) is gone over line by line and run without saving the corresponding machine code separately. (e.g., Python). Generally, compiled languages are faster to execute than interpreted languages.

Phases of a program written in compiled languages

Source code creation

A programmer writes code in a high-level language of their choice.

Object file creation

The code that the programmer writes goes to a program called the compiler, which checks it for syntax errors. The compiler then creates a file known as the object file that contains the machine code instructions corresponding to the high-level language.

Executable file creation

Complex programs are usually written in multiple files. A program called the linker takes in the object file and links it to the other relevant files to produce the executable file.

Get hands-on with 1400+ tech skills courses.