5 ms·
Java and Python are on the same level in relation to the hardware. They both get compiled to bytecode instructions that get executed by a virtual machine (basic
by kyllo 13y ago
Java and Python are on the same level in relation to the hardware. They both get compiled to bytecode instructions that get executed by a virtual machine (basically a software program that is pretending to be a processor). The source code for that virtual machine is written in C or C++. In order to execute Java code or Python code, the machine must have the VM installed. But it doesn't matter what type of processor you are running the code on, just as long as it has the VM installed.
A C/C++ compiler takes your source code and then compiles & assembles it to binary machine instructions that are executed directly by the processor. It is not necessary to have a C/C++ compiler installed on a machine in order to execute that binary. But the code must have been compiled to the machine language that type of chip understands. That's why you can't take a program that was compiled for an Intel chip and then go run it on an ARM chip. The different chip won't understand the instructions. So you have to compile the C source separately for each type of target chip.
That's why C is considered more low-level than Java and Python. The output of the compiler is executed directly by your processor hardware, instead of by a VM.
- pjmlp 13y ago> The output of the compiler is executed directly by your processor hardware, instead of by a VM. You mean like RoboVM, Aonix Perc and Excelsior JET? Just to name three possible native code compilers for Java.
- kyllo 13y agoYeah, and there are also C/C++ compilers that target JVM bytecode. I am aware of the difference between a language and an implementation.
- pjmlp 13y agoThat is not what I could infer from your statement.
- kyllo 13y agoThat's because I was responding at a level of detail appropriate for the parent comment: I thought Java was on a much lower level than Python. Why is C more low-level? At that level of understanding, I think it is just fine to assume that Java means Oracle JVM, Python means CPython, and C/C++ means gcc (or your choice of C-to-native compiler). Yes there are many alternative implementations of these languages, but for the most part those are pretty obscure and a beginner does not need to know or care about them just yet.
- pjmlp 13y agoWhile I agree with your comment in spirit, I would like to point out that this is how beginners get messed up with implementation and language concepts.