What is Programming?
The roots of man-machine relationship runs back to thousands of years. Today, we manipulate various kinds of machines. Out of myriads of machines available for the human, the computer has become the foremost, due to the fact that it is programmable and versatile.
Like all other machines, computers are not wise. But it is made to obey and work according to a set of instructions given by the human. These instructions are stored in the computer’s memory and the computer is allowed to follow them in the given sequence. Thus computers provide a close association with human in the context of solving real world tasks. This has paved the way to, what is called “Computer Programming”.
Programming
The core activity in the process of instructing a computer in solving problems is known as programming.Program
An ordered set of instructions given to a computer to accomplish a given task is known as a program.[ Programming is the art of designing, coding, modifying and testing programs.]
Man-Machine Communication
Conveying human thoughts to a computer in solving problems is not easy. Human beings are intelligent. They use natural languages, signals, symbols etc. in exchanging ideas among them.Computers on the other hand are dumb. They can only understand their native language called
machine language, which comprises of streams of bits and bytes. So one choice of programming a
computer is to use machine language, in its native form.
Early Stages in Programming
The earliest computers were not programmed in the same way as today’s computers, instead theprograms were hard-wired into the machine and the physical wiring was done by hardware experts. In order to modify such a program, the programmer had to rearrange the wiring.
It was not long before John Von Neumann exposed the concept of sharing the same memory by both programs and data. In this case the programs were entered into the memory through a switch panel as a stream of bits.
Machine Oriented Languages
Programming a computer in machine language is an extremely difficult process. Machine language is tedious, because so much of program code is needed to accomplish even simple tasks. One should know the internal mechanism of the PU thoroughly to work with it. Machine language also differs from PU to PU and is difficult to read and modify.To make the programmer’s job little easier, another type of programming language called Assembly Language was developed. An instruction in assembly language is in an ‘easy to remember’ form called a mnemonic.
For example instructions to add, subtract, multiply and divide in machine language and assembly
language might look like as follows
M/C Instruction Assembly Instruction (mnemonic)
0000000111011000 ADD
0010100111011000 SUB
1111011111100011 MUL
1111011111110011 DIV
The main problem with assembly language when compared to machine language is that an assembly language program cannot be directly executed by a computer. It needs another program to read assembly code and translate it into machine language. A program that performs this task is called an assembler.
Development of the assembly language and assemblers placed the programming task in the correct
track, but the programmers did not get much relief as they were still forced to think in terms of bits and bytes.
Getting Closer to Natural Languages
Human thoughts originate in its natural form. Natural languages (English, French, Germen, etc.) play the major role in expressing human ideas. Therefore the development of computer languages those closely resemble natural languages was essential to program computers. Such languages arecommonly known as High-level languages. Some examples of high-level languages are PL/I, COBOL, FORTRAN, BASIC and Pascal.
Today there are more than two thousand high-level languages available for programming computers.
Each language has its own objective and structure. For example the BASIC (Beginner’s All purpose
Symbolic Instruction Code) and Pascal languages are originally intended to teach computer
programming; while COBOL (Common Business Oriented Language) is intended to create business
applications such as Payrolls, Stock Control Systems and so on.
Some of the primitive high-level languages are being used extensively even today. This is due to the fact that they had been continuously updated to suite the trends in Information Technology.
For example the BASIC language was developed in 1965. Since then it has been subjected to many
developments and today, its newest version, Microsoft Visual Basic, is used in Rapid Application
Development (RAD). In contrast to high-languages, machine language and assembly language are
known as Low-level languages.
However, C language is unique among most of the high-level languages. It is neither high-level nor lowlevel.
It is rather considered mid-level as it can replace assembly language and still perform high-level
operations Once again, a disadvantage of high-level or mid-level languages is the necessity of a
translator to translate the program code (source code) into machine code (object code).
There are two types of translators used for this purpose; namely an interpreter and a compiler. An interpreter translates one line of code at a time and executes it immediately. An example of a popular interpreter is Microsoft GW-BASIC. Interpreters are more suitable for novice programmers who write small programs and they can run each statement of the code, observing errors and correcting them. Interpreters are not so suitable for large programs where time matters.
A compiler on the other hand reads the whole source code form the beginning to the end and translates it into an object code. Therefore compilers detect errors in advance. An error that encounters in compilation process is known as a compile time error. Such an error has to be corrected and recompiled before the execution.
However, after the compilation the object code is available for execution at any time. The advantage of compilation is that, the compiled code is very compact and runs fast. The disadvantage is that, each time an error is corrected it has to be recompiled.
A brief overview of programming techniques
In the early stages of computing, people neither have powerful computers nor intricate problems to solve as in today using computers. Both the programmers and the users were mostly computer professionals. Yet, programs were written but, in an unstructured way using a handful of programming languages.An unstructured program consists of one main program module containing the sequence of statements. The data being used in the program are globally visible. i.e. common to the whole program. The suitability of unstructured programming is mostly limited to beginners who write simple programs or small utilities.
However, with the rising demand for IT applications, the things got changed. Today we have
multifarious problems to solve in business, science, industry and everyday life. The most of the
computer users are not computer professionals. So we need more sophisticated and user-friendly
programs to outfit the current trend in Information Technology.
The ability of programmers to organize well-structured solutions to problems is of major importance. In an effort to produce well organized, reliable, easily maintained and efficient programs, a number of guidelines and methodologies were developed.
Procedural Programming
A procedure or function is a self-contained program module that executes a set of specific instructions.The procedural approach focuses on the procedures that must be enacted in order to solve a particular problem. Thus a program can be viewed as a sequence of procedure calls. A procedure calls another (calling procedure) for services. After the sequence of statements in the called procedure is processed, the flow of control continues right after the point where the call was made. A procedure also can call a sub-procedure and in any case, calling procedure and the called procedure are allowed to exchange data in some way.This form of programming has been in existence the longest, and is still in use today by many
programmers.
Structured Programming
Structured programming can be seen as a subset or sub-discipline of Procedural programming, one of the major paradigms (and probably the most popular one) for programming computers.It is possible to do structured programming in almost any procedural programming language, but since about 1970 when structured programming began to gain popularity as a methodology, most new procedural programming languages have included features to encourage structured programming, (and sometimes have left out features that would make unstructured programming easy).
Some of the better known structured programming languages are : Pascal, Ada
At the level of relatively small pieces of code, structured programming typically recommends simple, hierarchical program flow structures. These can be obtained in most modern languages by using only structured looping constructs, often named "while", "repeat", "for". Often it is recommended that each loop should only have one entry point and one exit point, and a few languages enforce this.
Object Oriented Programming
Object Oriented Programming is a modern, popular approach to programming which transcends the different generations, and represents an approach and methodology which is becoming the norm rather than the exception.C++ is the object oriented extension of the C language.
Note that C++ (which we use) incorporates C, meaning that it is possible to use OO languages to program in a procedural manner.
In procedural programming, the main emphasis is on the tasks necessary to effect a solution to the problem - the data on which the procedures act is the secondary focus.
In object-oriented programming the emphasis is reversed with the data being of prime importance and the procedures that act on that data assuming secondary focus.
The OO approach is seen as essential as software projects become more complex.
No comments:
Post a Comment