Java “Virtual Machine” vs. Python “Interpreter” parlance?

后端 未结 13 638
春和景丽
春和景丽 2020-11-29 14:45

It seems rare to read of a Python \"virtual machine\" while in Java \"virtual machine\" is used all the time.

Both interpret byte codes; why call one a virtual machi

13条回答
  •  孤独总比滥情好
    2020-11-29 14:57

    Interpreter, translates source code into some efficient intermediate representation (code) and immediately executes this.

    Virtual Machine, explicitly executes stored pre-compiled code built by a compiler which is part of the interpreter system.

    A very important characteristic of a virtual machine is that the software running inside, is limited to the resources provided by the virtual machine. Precisely, it cannot break out of its virtual world. Think of secure execution of remote code, Java Applets.

    In case of python, if we are keeping pyc files, as mentioned in the comment of this post, then the mechanism would become more like a VM, and this bytecode executes faster -- it would still be interpreted but from a much computer friendlier form. If we look at this as a whole, PVM is a last step of Python Interpreter.

    The bottomline is, when refer Python Interpreter, it means we are referring it as a whole, and when we say PVM, that means we are just talking about a part of Python Interpreter, a runtime-environment. Similar to that of Java, we refer different parts differentyl, JRE, JVM, JDK, etc.

    For more, Wikipedia Entry: Interpreter, and Virtual Machine. Yet another one here. Here you can find the Comparison of application virtual machines. It helps in understanding the difference between, Compilers, Interpreters, and VMs.

提交回复
热议问题