Program Compilation
When programmers create software programs, they first write the program in source code, which is written in a specific programming language, such as C or Java. These source code files are saved in a text-based, human-readable format, which can be opened and edited by programmers. However, the source code cannot be run directly by the computer. In order for the code to be recognized by the computer’s CPU, it must be converted from source code (a high-level language) into machine code (a low-level language). This process is referred to as compiling the code.
Most software development programs include a compiler, which translates source code files into machine code or object code. Since this code can be executed directly by the computer’s processor, the resulting application is often referred to as an executable file. Windows executable files have a .EXE file extension, which is often hidden.
Program interpreter
An interpreter is a program that reads and executes code. This includes source code, pre-compiled code, and scripts. Common interpreters include Perl, Python, and Ruby interpreters, which execute Perl, Python, and Ruby code respectively.
Interpreters and compilers are similar, since they both recognize and process source code. However, a compiler does not execute the code like and interpreter does. Instead, a compiler simply converts the source code into machine code, which can be run directly by the operating system as an executable program. Interpreters bypass the compilation process and execute the code directly.
Since interpreters read and execute code in a single step, they are useful for running scripts and other small programs. Therefore, interpreters are commonly installed on Web servers, which allows developers to run executable scripts within their webpages. These scripts can be easily edited and saved without the need to recompile the code. While interpreters offer several advantages for running small programs, interpreted languages also have some limitations.
The most notable is the fact that interpreted code requires and interpreter to run. Therefore, without an interpreter, the source code serves as a plain text file rather than an executable program. Additionally, programs written for an interpreter may not be able to use built-in system functions or access hardware resources like compiled programs can. Therefore, most software applications are compiled rather than interpreted.