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

22

u/[deleted] Apr 25 '21

I don't think assembly is a requirement but yes every language gets turned into machine code. It's just a matter of WHEN. Compiled languages and turned into machine code before you run the code. So a compiled language turned into an exacutable file is fully compiled. Meanwhile, interpreted languages are always compiled as you run the code. So a interpreted exacutable would likely be a bunch of text files that get compiled while you're using the program. Wither way, every language needs to convert the code to machine code.

2

u/dgpking Apr 25 '21

Another question... what’s reason/benefit of using compiled over interpreted?

6

u/Knaapje Apr 25 '21

Compilation allows the code to be optimized on the lowest level - the instruction set of whatever hardware you compiled for. There is also no overhead of running the interpreter whenever you want to execute your code.