What converts vbscript to machine code?

自闭症网瘾萝莉.ら 提交于 2019-12-08 00:51:37

问题


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?


回答1:


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.




回答2:


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




回答3:


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.




回答4:


Referring to this VB Script wikipedia article,

  1. When VB script is executed in a browser it uses vbscript.dll to interpret VB script.
  2. When VB script file is executed from command-line or a batch file then cscript.exe is used to interpret VB script.
  3. 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.


来源:https://stackoverflow.com/questions/9487426/what-converts-vbscript-to-machine-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!