0% found this document useful (0 votes)
8 views3 pages

Lecture XIII

Uploaded by

ayetheint121020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Lecture XIII

Uploaded by

ayetheint121020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Lecture XIII- An Introduction to Programming Language – II

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:

Example of Source Code


Figure: Hello World Program of C++

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]

 During compilation, compiler prompts the user for any errors.


 Once compiled, program can be executed repeatedly without the need for re-
compiling.
 An advantage of compiled code is that it can be taken to any machine with the
same CPU for execution and it doesn’t require compiling again.
e.g, C, Perl, CGI.

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”.

You might also like