Difference between Compilation and Interpretation
Here we are going to discuss difference between compiled languages and Interpreted languages. There are plenty of time waste video tutorials and texts which does not clear the definition of interpretation. We clear this thing in one short paragraph without wasting your time further.
Compilation meaning gather information. In terms of Compiler what information does it gather? and What it does with that information?
Answer is below:
Preprocessor ——> hello.c —-> Compiler —–> Object Code ——>Linker ——–> Executable File.
In the above structure, Preprocessor takes place first and replaces all the references which we have provided in Preprocessor directives. (We will learn about preprocessors in later chapter). After that our source code will be replaced by all preprocessor values, it is ready to be compiled. Compiler takes this in and provide us with Object Code of our source code. Now linker takes place and check for the library references in the Object code (hello.obj) of our hello.c file. Once it finds those references, it will load precompiled library files as per need. Once these all the information is gathered, it will finally link them all and put together as an executable file.
Now, in interpreted languages,
source file ——> Interpreter Platform (Virtual Machine) ——-> Executable File.
Above each and every instruction of source file is executed line by line as Interpreter (The VM – Virtual Machine) converts instructions line by line into an executable format and executes on the fly by requesting operating system necessary instructions.
So The difference between Compiled Language and Interpreted Language is, A Compiled Language takes source code and produces native executable file optimizing object code. Whereas interpreted languages they have interpreter to do all things. It will interpret the instructions line by line and produce executable code on the fly for each line of the code.