Search code examples
javajvmprogramming-languagesplatform-independent

Why the other languages rather than java is not platform independent?


We call java as platform independent because java has a virtual machine, JVM, which can execute the bytecode independently in any platform.

But the JVM must be installed( or must reside) on that system.

Now, Why don't people create virtual machine like JVM for other existing languages and call those languages as platform independent?


Solution

  • Platform independence is not directly related with having a Virtual Machine. Platform independent development means that the software you develop can run on multiple platforms. This can also be achieved with C or C++ for example when using multi platform libraries as QT or boost (whatever your purpose is). It has to be mentioned that C and C++ don't run in a Virtual Machine. Other languages like Java and the .Net languages like C# are translated to bytecode and run in a Virtual Machine. To run the bytecode on different platforms you need a VM for those platforms. So the Virtual Machine has to be developed for every specific platform.

    And also you cannot simply create a Virtual Machine for C, it's simply not thought to run in a VM. You have both languages: those that run 'directly' and those running in a VM. And you can develop platform-independent software in both types of languages. To put it short: platform independence is not directly related to Virtual Machine (but of course instead of compiling a code once for every platform a VM requires only one compilation and allows direct execution on all platforms that have this VM, so having a VM makes things a bit easier.)