Why does only java have a VM?
Everyone knows about classic languages such as C++, Assembly and C. What's weirdly specific about Java is the java virtual machine, why does it need a VM to run when other languages don't need to, even python.
It checks, reads and verify the java bytecode and the intepreter/core of java. It's basically used in JRE and JDK.
JRE is obviously, for being able to run java code & apps. It also uses heap space for dynamic memory allocation for java objects.
JDK is for developing & building applications for java.
It says C++ directly compiles code to machine code, but apparently java uses an entire separate interpreter, like some other apps I used before that emulate.
Python also has a bytecode checker but it's not a virtual machine, so why does java need an entire virtual machine just to run code?
It checks, reads and verify the java bytecode and the intepreter/core of java. It's basically used in JRE and JDK.
JRE is obviously, for being able to run java code & apps. It also uses heap space for dynamic memory allocation for java objects.
JDK is for developing & building applications for java.
It says C++ directly compiles code to machine code, but apparently java uses an entire separate interpreter, like some other apps I used before that emulate.
Python also has a bytecode checker but it's not a virtual machine, so why does java need an entire virtual machine just to run code?
Comments
JAVA is a "write once, run anywhere" environment.
IOW, you build some code on an Intel based windows machine, and in theory, it would run on a PowerPC Mac.
So basically your telling me that if I wrote Java code on PC-DOS if possible, it could run on a m68k Mac, ARM Mac, Windows 10, Linux Debian and even FreeBSD if it was all supported
https://www.ibm.com/docs/hu/aix/7.2?topic=monitoring-advantages-java
Advantages of Java
2024-08-29
Java™ has significant advantages over other languages and environments that make it suitable for just about any programming task.
The advantages of Java are as follows:
Java is easy to learn.
Java was designed to be easy to use and is therefore easy to write, compile, debug, and learn than other programming languages.
Java is object-oriented.
This allows you to create modular programs and reusable code.
Java is platform-independent.
One of the most significant advantages of Java is its ability to move easily from one computer system to another. The ability to run the same program on many different systems is crucial to World Wide Web software, and Java succeeds at this by being platform-independent at both the source and binary levels.
Because of Java's robustness, ease of use, cross-platform capabilities and security features, it has become a language of choice for providing worldwide Internet solutions.
https://www.google.com/search?q=why+use+java&oq=why+use+java&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQLhhA0gEINTc1MWowajGoAgCwAgA&sourceid=chrome&ie=UTF-8
The entire idea of interpreted or virtual machines was around on early personal computers because nobody was sure what CPU the next machine would have.
The UCSD P-System is one example. One could write and compile a program for the UCSD P-System and in theory it would run on any machine.
There were also Smaltalk type VMs, and that includes VisiCorp Visi On. Had that been successful, it could have been easily ported to other systems.
Even the TI-99/4A's Graphics Programing Language was the result of uncertainty during the design phase about what CPU would ship in it. They could have gone with a Z-80, or TI's 8-bit CPU, but instead they shoehorned their 16-bit CPU in there.
Microsoft .NET was created at a time when Intel was threatening to pull x86 compatibility from their CPUs, and Microsoft wanted a way to keep some kind of binary application compatibility across these platforms.
P-Code virtual machines had a second advantage beyond portability. P-Code can use considerably less memory. Java was intended for tiny embedded systems at first. The memory savings come at the cost of performance.