DEV Community

Rishit Khandelwal
Rishit Khandelwal

Posted on

How does a compiler work?

I would like to know what goes on in the compilers, like gcc and rustc

Top comments (6)

Collapse
 
saptarshibasu15 profile image
Saptarshi Basu •

A compiler converts your written code into native machine code that is definitely using 0s and 1s and finally the code executes after your machine understands it. A interpreter also works similarly but it converts one line at a time!, and yeah these also picks you up at your syntax errors.
Hope this helped you!

Collapse
 
rishitkhandelwal profile image
Rishit Khandelwal •

Yeah but how does it convert the code into binary?

Collapse
 
saptarshibasu15 profile image
Saptarshi Basu •

machine code and binary are same things

Thread Thread
 
rishitkhandelwal profile image
Rishit Khandelwal •

i know, but how does println!("Hello"); get converted to binary

Thread Thread
 
saptarshibasu15 profile image
Saptarshi Basu •

then you should research more 'bout terminals and consoles

Thread Thread
 
rishitkhandelwal profile image
Rishit Khandelwal •

But how are terminals and compilers related?