Program
What is a program?
- A set of instructions that execute on computer to perform a particular task
- Instructions that run on CPU are in machine code
- instructions that are encoded in binary (1s and 0s)
- Human can not understand machine code directly
- But human can write programs in machine code
- A tedious, time consuming and very error prone task
- Need computer programming languages –to write a human readable code (source code) which can be converted into machine code
Solution
- Assembly Languages
- Sets of binary digits are replaced by mnemonics (ADD, MOV)
- Not user friendly, but easier than machine code
- It is hard to understand another person’s assembly language programs
- Assembler: translates mnemonics into machine code
- Assembly languages are second generation languages
- Machine code and Assembly languages are low-level programming languages
- Programming in low-level languages required expertise in the field
- High level programming languages allow to write programs in English-like symbols
- write algorithms in a human-friendly notation
- allow thinking at a higher level of abstraction than assembly or machine language supports
- Third generation languages
- Need to convert code in high level languages into machine code
- Compiler
- translates the whole source code in to machine code at once
- checks syntax errors
- produces an executable machine code (Machine dependent)
- Interpreter
- convert the source code of a program line by line to machine coed while the program is running
- Compilers VS Interpreters
- Compiler produces machine dependent MC at once
- Interpreter executes source code line by line in every execution of the program
- Compiler produces optimize MC that run faster on hardware
- Interpreter might execute a program slower than the compiled machine code for the same program
- It is easy to point out errors in a program with an Interpreter (Easy to debug)
No comments:
Post a Comment