Generally, computer programs are written in high-level languages. However, computers do not understand high-level languages. Computers only understand programs written in binary (0 and 1) which are called machine code. To convert high-level languages into machine code, we can use a compiler or an interpreter. However, there are differences between how an interpreter and a compiler works.
Compiler | Interpreter |
Scans the entire program and translates it as a whole into machine code. | Translates program one statement at a time. |
It usually takes a large amount of time to analyze the source code. However, the overall execution time is comparatively faster than interpreters. | It usually takes less amount of time to analyze the source code. However, the overall execution time is comparatively slower than compilers. |
Generates object code which further requires linking, hence requires more memory. | No object code is generated, hence are memory efficient. |
Programming languages like C, C++, Java use compilers. | Programming languages like JavaScript, Python, Ruby use interpreters. |