r/AskComputerScience • • Apr 25 '21

Does all programming turn into machine code?

I don’t know if this question makes sense but when you write code in whatever language, python, C, Java etc does it all eventually get converted into assembly and then machine code?

35 Upvotes

32 comments sorted by

View all comments

6

u/Knaapje Apr 25 '21

Nope, some languages are compiled (like C), and some are interpreted (like Python). There are also some intermediate stages where source code is compiled to a bytecode which is interpreted (for example Java).

3

u/a4555in Apr 25 '21

I think yes, all code does eventually get converted to machine code as that's the only thing that a CPU/GPU understands.

Wouldn't all code eventually get translated to CPU machine instructions regardless of where it came from? I would assume the JVM translates bytecode to machine code in order to run it on the CPU.

4

u/Tornado2251 Apr 25 '21

Yes everything that is run is always machine code in the end.

But all code is not necessary being used. It can be optimized or changed in some of the intermediate steps. C is often used as the example as the process is pretty straightforward (especially if optimization is turned off). JIT and other runtime stuff makes it a lot more complicated.