This is the final lecture note for Software Development subject.
Compilers and Interpreters
A compiler is a program translator used for translating source program of high level languages in to machine executable form. That is the compiler is a program that takes in the C/C++ file(s) as an input and outputs an executable file that can then be directly run on the host computer.
Compilation Process
Compilation process consists of three stages;
Lexical Analysis
The source program of the programming language is scanned by the lexical analyzer to identify the commands, operators, identifiers, and tokens. After the identification it builds the syntax tree to detect any syntax or semantic errors.
Code Generation
During this stage for each and every rapid statement in the program machine code instructions are generated to prior the object program. In addition code optimization techniques are used to improve the efficiency of the program.
Linking
In the final stage separately compiled object codes in the external library functions are integrated to produce the final executable program.
If compilers are one extreme to running programming languages then pure interpreters are the other extreme. Pure interpreters do not do any code translation as done by compilers. These interpreters take the source code (which is written in a high language) and start executing the statements on the host machine one by one.
Comparison of compilers and interpreters
Compilers:
- Translated the whole program at once to produce the object code
- Can run the program independently
- Repeated executions do not need re-translation of the code
- Syntax and sementic errors are detected before execution of the program
- Execution speed is much higher
- Run time memory requirement is less
- Source program code is hidden from the user
- Translator execute the program statement by statement (line by line)
- Program is run under the control of the interpretor
- Every execution need to re-translate the program
- Errors are detected at the run time only
- Execution speed is much slower
- More memory is required at the run time
- Most of the time program source code can not be hidden
Some of the commercial programming languages have been known to be interpreted (Basic, Java) and yet these languages do not behave quiet like the description given above. The reason is simple - none -of the popular modern programming languages are pure-interpreter based. They are either compiled (like C/C++) or adopt a Hybrid approach (like Java, Basic).
Assembler
Assembly language is the closest thing you come to machine code It's a low level language which means that isn't as intelligent as high level languages like C or Pascal. It's harder to code in than those programs, but it runs much faster and you have total control of what you are doing. you should write programs all in assembly but use it as inline assembly in high level languages where you want it to run faster. Simplifies the task of writing machine code programs.
System software is really an amazing topic to discuss, plus it also creates a basis for one's concept of software engineering. I really liked the topic you have chosen.
ReplyDeleteAwesome blog. I would love to see true life prepared to walk, so please share more informative updates. Great work keeps it up. hostgator coupons renewal
ReplyDelete