How programs are Executed?

First of all you have to understand how the programs are executed from source code. It is very important to understand the working of any language or program. There are really two types of ways to execute program from source code and they are:

1. Interpreters

Interpreter reads the program line by line and then translate it to the machine code and then executes it. It needs the source code again and again for executing. Python, Java and PHP etc. are the language of interpreter. Every time you access a web site each page is executed with the reference of the source code. The process involves steps as:

Source Code    ===>     interpreter     ===>     Output

2. Compilers

Compilers reads the whole program and then translate it completely before giving an output. It doesn’t need the source code again and again. The compiler make a execute file which is distributed and on executing give the same output. This process involves many steps as under:

Source Code     ==>     Compiler     ==>     Translated to machine code     ==>     Object Code      ==>     Execute     ==> Output

When you compile a program, the compiler usually operates in orderly sequence of the phases called passes. The sequence happens approximately like this:

  1. First the compiler reads the source code, perhaps generating an intermediate code (such as pseudo-code) that simplifies the source code for subsequent processing.
  2. Next, the compiler converts the intermediate code (if there is any) or the original source code into an object code file, which contains machine language but it is not executable. The compiler builds a separate object file for each source file. These are only temporary and are deleted by the compiler after compilation.
  3. Finally, the compiler runs a linker. The linker merges the newly created object code with some standards, built-in object code to produce an executable file that can stand alone.

Language C

C is a Compiler execution program that is made up of, among other components, variable and functions. A variable is a way to hold some data which may vary, hence the name. For example, a variable might hold some the number 17 and later the number 41 or another variable might hold the word “Sue”. Every program has its own file extensions and in C the extension of files are as below

File names and extensions

Source code file

program_name.c

Object file

program_name.o

Executable file

program_name.exe

Header file

name.h

Library file

libname.a or libname.so

A function is a segment of text in the source code of a program that tells the computer what to do. Programming consists, in large part, of writing functions.

Advertisements
Tagged
%d bloggers like this: