Question-4: Can you please map the following
Compiler
Interpreter
Runtime
Source Code
Answer:
- In this case your code would be translated in a Machine Language.
- In this case your source code would be directly execute the instructions written in a programming language.
- Your compiled code can be executed using this.
- This is a file which contain your instructions written High Level Programming Language.
Exp:
Converting Programming Language to Machine Language
- Computer can understand only Machine Language.
- Hence, Programming language needs to be converted into Machine Language.
- There are two possible ways by which programming languages can be converted into Machine Language
- Compilation
- Interpretation
Program Compilation
- In this case your program or source code would be translated into Machine Language.
- As many times you change your source file, it needs to be compiled again.
- Once compiled it generate compiled version of the code, which you can distribute and people can execute it.
- For example, “.exe” file is a compiled code. Which contain Machine Language and you can give that *.exe file to anybody. He can execute that on Windows Machine.
Program Interpretation
- In case of interpretation program has to be translated each time you want to run. It’s not one-time activity as compiling once and run anywhere.
- There is interpreter required to translate your program each time it is translated.
- Hence, distributing your source code would not help until and unless end user does not have interpreter.
Compilation or interpretation
- Hence, high level programming languages are based on either compiler based or interpreter based.
- However, there are few languages which are based on either compiler and interpreter both.
How program is read or translated by compiler or interpreter
- Interpreter or compiler read your source file line by line.
- Check syntax and semantics of the code.
- If everything is fine, it moves to next line.
- In case there is any issue on a particular line. Compiler or interpreter will stop there and give error.