Monday, 2 March 2015

Running a Program


After a program is developed using a programming language, it should be executed by the computer. Programmers write programmes in human readable languages called high-level languages. However, the computer understands only 1’s and 0’s (referred as the machine language3 or machine code). Therefore we need to convert the human readable programs into a machine language before executing. This is conversion is achieved by a special set of programs called compilers (or interpreters). These programs convert the high-level language program, into machine language programs.


                         
                     Figure 1.1 – Converting a human readable program into machine language


Compilers translate a source program (human-readable) into an executable (machine-readable) program (Figure 1.2). Executable machine code produced by a compiler can be saved in a file (referred as the executable file) and used whenever necessary. Since the source program is already compiled, no compilation is needed again unless the source program is modified. The saving on the compilation time is an advantage that is gain from compiling and therefore these programs run much faster. Programs written in programming languages such as FORTRAN, COBOL, C, C++ and Pascal must be compiled before executing.

                                  

As in Figure 1.2 when the executable file is available it can be executed by providing necessary input
data so that it produces the desired outputs. Interpreters convert a source program and execute it at the same time (Figure 1.3). Each time the program runs, the interpreter converts high-level language instructions and input data to a machine readable format and executes the program. This process can be slower than the process which compiles the source program before execution. The program need to be converted as well as executed at the same time. Programs written in languages like BASIC, Perl, Smalltalk, Lisp and VB Script are interpreted.


No comments:

Post a Comment