Title: What converts vbscript to machine code?
Tags: interpreted-language
Question: Compiled languages like C# and java, have just in time compilers, that convert them (from byte code) into machine code (0s and 1s). How does an interpreted language like VBScript get converted into machine code? Is it done by the operating system?

Comment: It's done by vbscript runtime (vbscript.dll) which parses&interprets the code on the fly as it's run, and calls own' internal functions such as alert() (which are already in assembly language). So basically it's like compilation, but during the program' run.

Comment: user1227804, I like your response. Can you please post it as an answer?

Here is the accepted answer: They don't necessarily get converted to machine code (and often don't).

The interpreter for that program runs the appropriate actions according to what the program requires.

Some interpreters might generate machine code (using JIT compilers), others might stick to plain interpretation of the script.

Comment for this answer: Not the OS. The interpreter (wscript.exe for example) reads the source script line by line and calls functions to do what the script wants to be done (this is way overly simplified, but it's the idea). The interpreter and the functions it calls are compiled code, like any other compiled program.
Comment for this answer: No, it doesn't have to. All the code is already in the interpreter itself, it doesn't need to produce additional machine code (though it can).
Comment for this answer: How does the processor get instructions? (All work is ultimately done by the processor) Is it that the OS interprets the code and send the appropriate instructions to the processor?
Comment for this answer: Ahh..so interpreter is the one that generates the machine code.
Comment for this answer: I think the fairer analogy is that CPU executing machine code is analogous to an interpretor reading regular code. CPU parses each instruction using circuits and   sets various state to which other circuits respond to; while an interpretor parses the whole code into an internal object literal notation that it can actually understand without doing text manipulation on it, then it maps the  requests to perform stuff to the actual native dispatchers or its own bytecode that has already been compiled by the interpretor's compiler or that will also get interpreted on demand.

Here is another answer: Referring to this VB Script wikipedia article,


When VB script is executed in a browser it uses ```vbscript.dll``` to interpret VB script.
When VB script file is executed from command-line or a batch file then  ```cscript.exe``` is used to interpret VB script.
When VB script is used by Windows OS itself for various purposes like showing error message boxes or yellow colored notification messages in the right corner of the task bar then it is interpreted using ```wscript.exe``` which is a windows service.



Here is another answer: I know this is old, but given that I can't comment (rep), I want to add a clarifying answer:

An interpreter is used to interpret the script (be it VBScript, javascript, python, or any other script) into individual instructions.  These instructions can be in the form of machine code or an intermediate representation (that the OS or other program can use).  Some interpreters are made for something closer to assembly language and the source code is more or less executed directly.

Most modern scripting languages (eg, Python, Perl, Ruby) are interpreted to an intermediate representation, or to an intermediate representation and into compiled (aka machine, aka object) code.  The important distinction (vs compiled languages) is that an interpreter isn't taking an entire body of code and translating its meaning to machine code, it's taking each line at a time and interpreting its meaning as a standalone unit.

Think of this as the difference between translating an entire essay from English to Russian (compiled code) vs taking each sentence in the essay and translating it directly (interpreted code).  You may get a similar effect, but the result won't be identical.  More importantly, translating an entire essay as a total body of work takes a lot more effort than doing one sentence at a time as a standalone unit, but the whole translation will be much easier for Russian speakers to read than the rather clunky sentence-by-sentence version. Hence the tradeoff between compiling code vs interpreting code.

Source:  https://en.wikipedia.org/wiki/Interpreter_(computing), experience


Here is another answer: This is the answer I was looking for. Like javascript engine, there used to be a vbscript engine, that converted human readable code to machine code. This vbscript engine is analogous to the JIT compiler in CLR and JVM. Only that it converts directly from human readable code to machine code. As opposed to C# having an intermediate byte code.

Comment for this answer: The wikipedia link that you have mentioned in your post has no mention of vb script or vb script engine. I believe you wanted to refer [VBScript wikipedia](https://en.wikipedia.org/wiki/VBScript)

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 4, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2012:00:02/28/12', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<interpreted-language>', 'Title': 'What converts vbscript to machine code?', 'ViewCount': 2179, 'id': 9487426, 'user_AboutMe': "<p>&quot;Abstractions save us time working, but they don't save us time learning.&quot;-Joel Spolsky</p>\n", 'user_AccountId': 1122367.0, 'user_DisplayName': 'developer747', 'user_Reputation': 14538.0, 'user_Views': 777.0, 'user_id': 1110437.0}}