Why is pure interpretation more preferred for scripting languages compared to programming languages. I mean why for scripting languages program is not converted to machine language and then executed. From what I have read, one of the reason is speed, for scripting purposes speed is not so important and because interpretation is slower so it does not matter for scripting languages. Are there more reasons for using interpretation in scripting ?
2 Answers
Some of your assumptions are incorrect.
However, the normal reasons for choosing interpreting rather than compiling (to machine code) are:
it is easier (less effort) to implement an interpreter,
interpreters are easier to port to multiple platforms,
compilation to native code takes time, which can slow down the development cycle and / or lead to longer application startup times in the JIT compilation case1.
1 - The latter is complicated, and it it is difficult to do an even-handed comparison. The flip-side is is that after the slow startup, the JIT-compiled program runs much faster than interpreted code, and possibly faster than statically compiled code.

- 698,415
- 94
- 811
- 1,216
-
Thanks but I have read in a similar question that interpreters take much more time. Here is the link to the question- http://cs.stackexchange.com/questions/9945/how-does-interpreting-a-script-work – geek123 Nov 19 '15 at 07:45
-
@geek123 - That in no way contradicts what I wrote. Time to implement != time to run. – Stephen C Nov 19 '15 at 07:49
Scripting, and especially an interactive scripting (command shells, etc.) is most often for the code which runs only once, and in such a scenario latency is more important than anything else. JITs won't be of any use in this case. You'd expect a feedback from your REPL immediately, and waiting for each of your commands to compile before executing them is rarely justified.
Therefore, an ad hoc interpretation or, better, a very lightweight compilation (e.g., compiling to a high level VM which is then interpreted) is preferred to a proper heavyweight compilation.

- 9,605
- 1
- 23
- 35