I was going through important JS interview questions, and came across a topic , Difference between scripting and programming language.
Let's have a look into it :-
Before comparing we have to know about how your code gets executed:-
Our source code is written using human language that computers cannot understand, so this source code is converted into bytecode, which the computer can understand.
In between this conversion, there comes either of the two things: a compiler or an interpreter.
A compiler first optimize the entire code(source code to bytecode), and then it gets executed.
But in an interpreter, the code will run line by line, and at the same time, the lines will be converted into bytecode.
Now, the main difference between a programming and a scripting language lies in the use of a compiler or an interpreter.
A scripting language uses an interpreter for source code conversion, whereas a programming language uses a compiler. Every scripting language is a programming language, but not all programming languages are scripting languages.
Example:-
Scripting language: JavaScript, Python
Programming language: C, C++ , Java
But,but,but , here comes JIT compilation into play.
What is JIT??
Just in time compilation was added to JavaScript to improve code execution. The V8 JavaScript engine introduced it for the first time. So how does this work, and why was there a need for a it?
The use of interpreters in JavaScript made code execution slow because the code is executed line by line while converting it into bytecode.
However, a JIT compiler converts the JavaScript code into bytecode just before it is executed, this makes the execution faster. In simple words:- JIT compilation=Interpreter + Compiler.
Top comments (0)