r/learnpython • • Mar 06 '15

Is python a machine level language?

I'm still learning high-level programming languages (currently C# & Ruby) but eventually want to move to something that is more directly involved with the actual processor & memory. I've seen alot of languages that claim to be compilation code & ever-so-powerful but still need a VM or some kind of translator to actually execute (COUGH COUGH JAVA). so id like to know, would python at all be considered compilation code?

0 Upvotes

18 comments sorted by

View all comments

1

u/ivosaurus Mar 06 '15 edited Mar 06 '15

Both Python and Java have a compilation step which compiles their language source into bytecode.

This bytecode is then separately, by some means, executed, to run the program.

Both bytecodes look quite different; and the details of the implementation that does the execution of them is also extremely different.

As a point of difference, C and C++ are said to be compiled languages; their compilation step typically translates their language source right down to machine instructions; which can be passed wholesale directly to a CPU to run.

Lastly, Python and Java differ in that the former usually integrates its bytecode-compilation step into its execution step. Executing a .py file first compiles the Python source, then immediately after executes the bytecode produce. Whereas Java usually separates this step - one first runs javac on Java source code, which outputs a bytecode file. You then run java on the bytecode.

The biggest difference between Java and Python is that Python is dynamically typed, and Java statically. In terms of execution environment, the default Java VM uses a JIT, while the default Python VM just uses a step-by-step interpreter.