Introduction to
Programming Language
• Programming languages are essential
tools used to communicate instructions to
computers.
• They bridge the gap between humanreadable code and machine-executable
instructions.
Computer Languages Category
– Machine Language
• Uses binary code
• Machine-dependent
• Not portable
• Assembly Language
– Uses mnemonics
– Machine-dependent
– Not usually portable
• High-Level Language (HLL)
– Uses English-like language
– Machine independent
– Portable (but must be compiled for different platforms)
– Examples: Pascal, C, C++, Java, Fortran, . . .
1GL: Machine language
– Computers only understand binary code
(0s and 1s) at their core
– The instructions are in the form of binary
code
• 1101101010011010
– It is closer to the computer's hardware and
less human-readable.
2GL: Assembly language
– Low-level programming language to
represent machine-language instructions
• E.g.: ADDF3 R1, R2, R3
– Assembly code need to be converted into
machine code by using an assembler
– Assembly program
• is platform dependent
• Combination of mnemonic and machine
instruction
3GL: High-level language
– English-like and easy to learn and program.
– E.g.:
• Area = 5 * 5 * 3.1415;
– COBOL, FORTRAN, BASIC, Pascal, Ada,
C, Visual Basic, Delphi, C++, C#, Java
– Source program is compiled into machine
code by a compiler and linked to
supporting library code by a linker to form
an executable file.
Compilation into Assembly
Language
Assembly
Language
Assembler
Machine
Language
Compilation
Source
Program
Compiler
Target
Program
Input
Target Program
Output
• Compiler translates source into target (a machine
language program)
• Compiler goes away at execution time
• Compiler is itself a machine language program,
presumably created by compiling some other high-level
program
• Machine language, when written in a format understood
by the OS is object code
Interpretation
Source
Program
Interpreter
Output
Input
• The interpreter stays around during execution
• It reads and executes statements one at a time
Program Execution
• Steps taken by the CPU to run a program
(instructions are in machine language):
1. Fetch an instruction
2. Decode (interpret) the instruction
3. Retrieve data, if needed
4. Execute (perform) actual processing
5. Store the results, if needed
Program Errors
• Syntax Errors:
– Errors in grammar of the language
• Runtime error:
– When there are no syntax errors, but the program
can’t complete execution
• Divide by zero
• Invalid input data
• Logical errors:
– The program completes execution, but delivers
incorrect results
– Incorrect usage of parentheses
Question ?