How does source code become a program?
Source code is the actual text used to write the instructions for a computer program, and this text is then translated into something the computer can understand. But how is source code converted into meaningful data for the computer?
This lesson focuses on:
- Parsing source code
- Compiling source code
- Interpreting source code
- Which languages go through which processes and why
Parsing source code
The word parsing is defined as breaking up into smaller parts. Before source code can be converted into meaningful data for the computer, it has to be broken up into parts. Through the use of parsing, source code gets broken down into smaller parts and then it is ready for the next step.
Compiling source code
Compiling source code refers to turning source code into an actual executable program.
When source code is compiled, it is turned into an actual program (machine code) through a series of steps:
-
Source code is turned into object code by a compiler.
Object code is the machine code that is actually executed by the computer. A compiler turns source code into data that the computer can understand, but it is not yet ready to become a program. Before object code can become a program, it has to pass through a program called a linker.
-
Object code is passed through a linker
A linker is a program that combines various modules and object code files into an executable program. Once the data is passed through a linker, an executable program comes to fruition.
NOTE: Machine code is platform specific. So for example, a program that is compiled on Windows will not work on Linux.
Interpreting source code
Interpreting source code refers to turning source code into an intermediate form which is executed by a program called an interpreter instead of turning source code directly into machine code like a compiler does.
An interpreter interprets the source code into something that the computer can understand.
Which languages go through which process and why
While code written in any programming language must be parsed, some code is compiled, and some code is interpreted.
Generally, code written in languages used for software application development such as C, C++, C#, and Delphi is compiled. This is because these languages are designed to create standalone executable programs, and as such, code written in such a language needs to be compiled.
Generally, code written in languages used for web development such as Javascript, VBScript, PERL, and PHP is interpreted. This is because these languages are designed to create web applications and display data on web pages. They are not used to create standalone executable programs, and as such, code written in such a language needs to be interpreted.
It is possible however, to either compile or interpret code written in a high level language. Depending on the purpose and circumstance, either operation can be applied to code written in a high level language. For example, an interpreter is sometimes used during the development stage of a program because the process of compiling a program (if it is a long program) can be time consuming.




