Difference Between Similar Terms and Objects

Difference Between Compiler and Interpreter

Compiler vs Interpreter

When writing programs in a high level language, the computer will not be able to understand it. So that it will be usable, you need to convert it into something that a computer understands. This is where compilers and interpreters come in as they both do the same function. The main difference between a compiler and an interpreter is when they execute the code. With an interpreter, the code is executed right away with the interpreting passing the interpreted code to the computer. In comparison, a compiler doesn’t execute the code. Instead, it writes the finished code into the disk. The code written to disk can then be executed any time.

The main difference between the interpreter and compiler spawns another one. Since the interpreter is needed when you run a program, you need to have an interpreter installed if you want to execute the program in your machine. This is not the case with a compiler. Once the program has been compiled, you just need the compiled program and not the compiler or the original code.

An advantage of using an interpreter rather than a compiler is the ability to execute the program on computers running different operating systems; given that you have the appropriate interpreter. When you compile a program, it would be for a specific operating system only and would not run on others. To make it run on another operating system, you need to optimize your code for that operating system and compile it again.

The downside of using an interpreter is the added overhead. An interpreter would need some processing power and each line of code would be interpreted during runtime. This is not the case when you have a compiled program because the operating system can read it directly and execute each command. The extra step of interpreting code makes the interpreted program to run significantly slower than compiled code. The interpreter would also not be able to take advantage of OS specific optimizations that can let a compiled program run more efficiently.

Choosing between a compiler and an interpreter should depend on whether you want portability or performance.

Summary:

  1. An interpreter directly executes the code while a compiler does not
  2. An interpreter needs to be available in the target machine while a compiler is not
  3. An interpreted program will run on multiple platforms while a compiled program won’t
  4. An interpreted program will run slower than a compiled program


Search DifferenceBetween.net :




Email This Post Email This Post : If you like this article or our site. Please spread the word. Share it with your friends/family.


Leave a Response

Please note: comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Articles on DifferenceBetween.net are general information, and are not intended to substitute for professional advice. The information is "AS IS", "WITH ALL FAULTS". User assumes all risk of use, damage, or injury. You agree that we have no liability for any damages.


See more about : ,
Protected by Copyscape Plagiarism Finder