Compiler and interpreter both are tools to translate source code from high-level language to machine language. Both does the same task of translation. But the working mechanism of compiler is different from interpreter. Below are some differences between compilers and interpreters
An interpreter is a program that translates source code written in high-level language to machine code. It is similar to compiler and does the same task of translation from high-level to low-level language. Despite of its similarity, the working mechanism of interpreter and compiler are different.
An interpreter does not translate whole code at once like compiler. Rather, is reads entire source code at once. Translates single instruction to machine code or some intermediate code. Then executes the translated machine code instruction immediately and translates next instruction if needed.