A friend new to programming asked me what is the difference between a saved shell script and a compiled executable binary file?
We were talking about the difference between compiled and interpreted languages. WHen I mentioned that compiled ones produce a binary code and interpreted don't and rather execute source code line by line, she asked what about when you save a shell script and run it later. Does that mean the script was compiled?
So what is the advantage of an interpreted language if you still save the script rather than compiling it??
I tried to argue that compiled l. are faster and interpreted more convenient for immediate results because there is no time wasted in compilation. But she got me with the above question about saved shell scripts.
she asked what about when you save a shell script and run it later. Does that mean the script was compiled?
It is still interpreted and not compiled. When you save C/C++ code is the same: It is not compiled. Compilation is a different process than saving. Saving implies storing the data as is, meaning the language statements. Compilation implies reading the human-readable code and transforming those into processor instructions, which are then saved.
Advantage of interpreted languages? You can deploy dynamic code easier. Take Javascript as an example.