Lecture XIII
Lecture XIII
Lecture Outlines
• Source Code
• Machine Code
• Compiler
•Interpreter
•Difference between compiler and interpreter
•Introduction to Python Programming
Source Code
•Source code is the list of human-readable instructions that a programmer writes—
often in a word processing program—when he is developing a program.
•The source code is run through a compiler to turn it into machine code, also called
object code, that a computer can understand and execute.
•Object code consists primarily of 1s and 0s, so it isn't human-readable.
•Source code and object code are the before and after states of a computer program
that is compiled.
•Programming languages that compile their code include C, C++, Delphi, Swift, Fortran,
Haskell, Pascal and many others. Here is an example of C language source code:
Compiling a program
• Compiling is the transformation from Source Code (human readable) into machine
code (computer executable).
• A compiler takes the recipe (code) for a new program (written in a high level language)
and transforms this Code into a new language (Machine Language) that can be
understood by the computer itself.
• The high-level programming language is also known as source code in a computer
program.
• However, computer machine does not understand these high-level programming
languages.
• It only understood its machine code, i.e., a program in 0's and 1's in binary form to
perform the task accordingly.
Compiling process
Figure: How a computer compiles a computer program [6]
Compiler
• A compiler takes the program code (source code) and converts the source code to a
machine language module (called an object file).
• So, for a compiled language the conversion from source code to machine executable
code takes place before the program is run.
Figure: How a compiler works
Interpretation a program
• In the case of interpretation (when computer program is Interpreted), the translation
happens when the user program is executed; thus it must be retranslated each time it is
run.
• When the program runs, a program known as an interpreter reads each line and
converts it to machine code at that time, and then executes it.
• Essentially, it gets compiled every time it is run. This process is also known as
“compilation on the fly”.