Why there is no virtual machine for other languages unlike Java?

245 views Asked by At

Why there is a need for Java virtual machine? One is able to run codes written in other languages without using their virtual machine, while java requires JVM to run the code. Why is it that we have a virtual machine for Java, while for other popular languages like C++ or python, there is no such virtual machine required?

3

There are 3 answers

0
nhgrif On

The Java Virtual Machine means that Java code runs on every machine with the correct version of the Virtual Machine on it.

Meanwhile, programs written in other languages that don't run on a Virtual Machine may need different compilations of the code in order to run on different operating systems.

0
jl2975 On

The main reason is so that java can be run on any os that can download the jvm and it will run the same way that it did on your computer.

0
supercat On

Java is perhaps the most popular virtual-machine-based language, but it is by no stretch of the imagination the only one. The .NET Framework uses a different virtual machine. None of the languages that target the .NET Framework have as much dominance in that area as Java has with the JVM, but many people use those languages for no other purpose except to write code for the .NET framework.

Historically, there have actually been quite a few languages which were virtual-machine based. Perhaps the most famous platform-independent VM prior to Java was the USCD P-system, which was probably most widely used on the Apple II series computers, but was also available for the PC. Some games like Wizardry which were based on the P-system and originally published for the Apple were later released for the PC; the PC versions of such games behaved almost exactly as the Apple versions, since they were running almost the same code.