Hello.
Recently I started learning virtual machines. There was such a question. There are some VMs, for example, Monty, Squawk. These virtual machines are partially or fully written in Java. This phrase has driven me a little into a dead end. (Due to lack of knowledge or understanding, probably).
We have a virtual machine written in low-level languages regarding Java - C ++, C, Assembler. It's all clear. The machine is written for each platform, tied to the hardware in low-level languages, in order to interpret the pseudo-code (bytecode) where the virtual machine is installed. This way cross-platform is achieved.
That is, we spend iron resources in order to raise a virtual machine on it, and then generate machine code for the platform at the execution stage. Due to the fact that we have an intermediate layer execution, a program written in such languages loses to compiled languages.
Well, actually the question. Why write a virtual machine based on another, or rather inside another. We have a Java VM on the device, why do we need to add another layer of abstraction? It turns out that we are writing a virtual machine based on the functionality that an existing VM on the device provides us. That is, in this way, we, first, cannot do more than the framing VM provides, besides we use additional computing resources of the computer.
I understand correctly?
Well, it can be assumed that this is convenient in some cases when all the functionality of the framing VM is not required or abstraction from the implementation in order to simplify the writing of the code.
Of course, if the computer provides resources, you can do so, and the difference will be almost imperceptible. But usually these VMs are used on mobile, portable devices. Where is the logic here? Why add an extra layer, okay, if it were free of charge with respect to resources, but this leads to a large expenditure of resources, which are very few on mobile devices.
Please explain the idea and benefits. Maybe I just misunderstand something, correct, please.
Thank you very much in advance.