Hello Steemiter,
What is the difference? Which one should we use?
Compiler is a program that transforms the code (source code) entered by a user into a desired code.
Interpreters, like compilers, perform the process of translating code from one language to another.
Compilers that run a source code after converting it to the target code, and therefore run the code to catch up the errors in the code and make the code better without running any more code. The compiler also runs the code in line or block and does not execute any lines that are not in the line. Those lines can not see the errors and can not make improvements called an interpeter.
Compilers are faster than interpreters. Because interpreters interpret each line one by one from the first line of code to the last line of code, and perform the operation for the code. Compilers translate the entire code into computer language. If there is an error, it reports all errors to the programmer. However, the interpreter reports the first error that is encountered, the first error can not be found until the error is resolved because the line is being processed in line.
As an example of program languages that use compilers; Pascal, C ++, Ada, Visual Basic, C and many more.
As an example of program languages that use interpreters; We can give you a lot of examples like HTML, XML, PHP, Script Languages.
One of the program languages that use both Compilers and Interpreters is JAVA. In Java, the code is compiled first and a code called byte code is generated that can be executed only in java virtual machines. This generated intermediate code is then executed in accordance with an interpreter structure in the java virtual machine.
Thank you for all of your support!