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

后端 未结 13 623
春和景丽
春和景丽 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:59

    I think the lines between both are blurred, people mostly argue around meaning of word "interpreter" and how close the language stands to each side of "interpreter...compiler" spectrum. None makes 100% however. I think it is easy to write Java or Python implementation which be of any value of the spectrum.

    Currently both Java and Python have virtual machines and bytecode, though one operates by concrete value sizes (like 32-bit integer) while other has to determine the size for each call, which in my opinion doesn't define the border between the terms.

    The argument that Python doesn't have officially defined bytecode and it exists only in memory also doesn't convince me, just because I am planning to develop devices which will recognize only Python bytecode and the compilation part will be done in browser JS machine.

    Performance is only about the concrete implementation. We don't need to know the size of the object to be able to work with it, and finally, in most cases, we work with structures, not basic types. It is possible to optimize Python VM in the way that it will eliminate the need of creating new object each time during expression calculation, by reusing existing one. Once it is done, there is no global performance difference between calculating sum of two integers, which is where Java shines.

    There is no killer difference between the two, only some implementation nuances and lack of optimization which are irrelevant to the end user, maybe up at the point where she starts to notice performance lags, but again it is implementation and not architecture issue.

提交回复
热议问题