Thursday, December 4, 2014

What is a computer program ?

What is the use of a bat if you don't know how to play Cricket ?
Completely useless, right ?
Same thing happens with computers without a program to run on it.

With that said, here comes a formal definition of a computer program.

Computer Program: In computing, a program is an organised set of operations for a computer to perform. Program is more like a recipe for a computer which consists of  a set of ingredients (which are known as variables) and a set of instructions(which are called statements) to tell the computer what to do with the variables.

Program has an executable form for computer to use directly. This form is not suitable for human being. This is also known as Low-Level program or machine language. The instructions provided in this form can be directly used by the processor. Another form of a program is High-Level program or source code, which is suitable for human reading or editing.

The human readable source code must be converted to machine readable low level machine code by a compiler or assembler or interpreter.

Source Code: Source code is a program written in a high level language (Such as C, C++, Java etc.). This is used by computer programmers who specifies the computer how to work. Source codes are often written in a text format. Source code is not machine dependent. You can write a program in Machine A and can run the same program in Machine B.

These are then provided to a special process, known as compiler as an input to produce a low level machine code understood by compiler.

Source Code Program written in High Level Language


Machine Code: Machine code or machine language is a set of instructions to be used directly in the computer's central processing unit. Machine language is completely machine dependent.

Every processor or processor family has its own set of instruction due to the architecture of the processor. So machine code written for a particular family of processor can not be run on a different family of processor.

Following is a program in its Hex form. This program runs and prints Hello World !

Machine code of a program
Following is the bit string provided to CPU to perform. This is the lowest form of a computer program.
Instruction to CPU in bits (0 and 1)



Prev Next
Palash Kanti Kundu

5 comments:

  1. Replies
    1. If you really liked my post, please share...

      Delete
  2. It really helps like us people, carry on.........

    ReplyDelete
    Replies
    1. If you liked my post, keep watching this space, I will add more when I get time and please share this blog...

      Delete
  3. I have to agree with your statement about source code, it is completely independent - you can run code on whichever machine you want!

    ReplyDelete