The difference between compiled and interpreted code lies in the point where the source code is transformed to machine level instructions, which provides two very different conceptions of running applications. In compiled languages as C, C++, Cobol or Fortran, a compiler, which is specific to the machine and often to the operating system, transforms the source code into executable code. On the other hand in interpreted languages like JavaScript, PHP, Perl, Python, Java or C# , the ultimate transformation to machine language is done at run time.
Compiled programs are already in the executable form native to the hardware and operating system that runs it and do not need to suffer any intermediate processing to be run (Brookshear, 2008). Therefore, compiled programs usually run faster than interpreted ones, which can be designed, like Java and C#, so they can call compiled languages to run application parts that have a critical performance (Spell, 2000). However, there are situations where just-in-time (JIT) compilers that use platform-specific, application-specific, environment or language optimization techniques (Bertino, 2000) can make an interpreted program to run faster.
For example, if a function or component is called multiple times, JIT compilers can optimise the code so that it can run potentially faster than compiled code. Another example, if a program is compiled for a i386 processor, it will not be optimised for a Core 2 Duo, however a JIT compiler can optimise the code to the particular hardware (Spell, 2000). Below, there is a comparison of languages performance and can be observed that the fastest language (for this particular benchmark) is C++ running on GNU/Linux and the second Java running on GNU/Linux, which is faster than C++ running on Windows (Warren, 2009).
Interpreted languages, on the other hand, can be separated into the ones that use a virtual machine, like Java and C# and those who don't, like JavaScript, PHP, Perl and Python. While Java and C# compile the source code to an intermediary level that, at runtime, is interpreted into native calls by the virtual machine, scripting languages are not pre-compiled. Nevertheless, it is possible to say that Java and scripting languages have a common origin in their success, the growth of Internet (Vinoski, 2006; Spell, 2000).
With the appearance of Internet, emerged the necessity to create software applications that could be run in all the different systems the network interconnected. This internet applications where intended to people running many different operating systems on many different platforms with different browsers. To resolve that problem, in the early 90s some engineers at Sun Microsystems designed the platform-independent Java programming language (Spell, 2000).
On the other side, interpreted scripting languages suffered a different evolution. For example, Perl, grew out of the system administration world and Python as an improvement to Perl, concerning PHP and JavaScript, they were designed to work in web environments. These languages were perfect for the constant need in the Web sites to change frequently, because in order to perform a small change in the code, the whole application has not to be compiled an redeployed (Vinoski, 2006).
Another type of interpreted programs are languages that want to take advantages of the scripting languages and the use of virtual machines. This projects use the JIT compiler in the virtual machines to interpret the scripting code. For example Jython is a Python implementation that runs on the Java VM and IronPython is a Python implementation for the Common Language Runtime used by C#.
Concluding, even native code execution is faster than interpreted code execution, it might not always be the best solution. Interpreted languages can make worth the trade-off between the loss of speed and the benefits form interpreted languages such as less memory consumption, straightforward cross-platform compatibility, easier deployment and maintenance and JIT's compilers runtime optimization.
src link: http://www.raulvm.com/information-systems.php/2010/12/09/interpreted-vs-compiled-languages
References:
Bertino, E., (2000), 'ECOOP 2000--object-oriented programming', 14the European Conference Sophia Antipolis and Cannes, France. Springer. pp. 362-363.
Brookshear, J.G., (2008). 'Computer Science: An Overview 10th ed.', Addison Wesley. pp. 296-311.
Spell, B., (2000), 'Professional Java Programming 1st ed.', Peer Information, pp. 1-21.
Vinoski, S., (2006), 'The language divide', Internet Computing, IEEE , vol.10, no.2, pp. 82- 84, March-April 2006.
Warren, M. R., (2009), 'C# versus C++ versus Java performance comparison', C# Architect [Online]. Available from: http://www.csharp-architect.com/ (Accessed: 2 April 2010).