1 What Is Programming
1 What Is Programming
1 What Is Programming
A problem is defined as any question, something involving doubt, uncertainty, difficulty or a situation
whose solution is not immediately obvious. A situation which is a problem for one person may not be
a problem for another person. Figure 1.1 graphically represents the concept of problem solving.
A Computer is a tool that can be used to solve problems by writing programs. Writing a program
without knowing the problem that we are trying to solve is like swinging a knife without knowing what
it is that we want to cut.
A program is a set of instructions that tells the computer how to do a task. When a computer follows
these instructions, we say it executes the program
and how they might be used in a simple flowchart of an everyday action preparing a letter for
mailing.
instructing the computer what operations to perform. There are many programming languages such
as BASIC, COBOL, Pascal, FORTRAN, C, etc.
Programming languages are precise like the English language. To get your program to work, you
have to follow the exact syntax (rules) of the language you are using. However, there is no
guarantee that your program will work because the syntax in programming language is correct. The
correctness of the language is the first step that you require. After that, the program must be keyed,
probably using a personal computer, in a form that the computer can understand.
Programs are most commonly translated using a compiler. A compiler translates the entire program
at one time. The translation involves your original program (Source file) which is transformed by a
compiler into an object module. Pre-written programs from a system library may be added during the
load/link phase, which results in a load module. The load module can then be executed by the
computer.
Debugging
Debugging is used extensively in programming. It means detecting, locating, and correcting bugs
(mistakes) by running the program. These bugs are called as logic errors, which tells the computer to
repeat an operation but not telling it when to stop repeating. In this phase we run the program using
the test data that we devise. We must plan the test data carefully to make sure we test every part of
the program.
1. Programming helps us to understand computers. If we learn how to write simple programs, we will
know better about how a computer works.
2. Writing a few simple programs increases our confidence level. We will find great personal
satisfaction in creating a set of instructions that solvea a problem.
3. Learning programming lets us find out quickly whether we like programming and whether we have
the analytical turn of mind that programmers need. Even if we decide that programming is not for us,
understanding the process certainly will increase our appreciation of what computers and
programmers can do.
Levels of Language
Programming languages can be "lower" or "higher," depending on how close they are to the
language the computer itself uses (0s and 1s = low) or to the language people use (English like
high). We will consider five levels of language. These are numbered 1 through 5 to correspond to
generations. In terms of ease of use and capabilities, each generation or level is an improvement
over its predecessor.
The five generations of languages are:
1. Machine languages
2. Assembly languages
3. High-level languages
4. Very high-level languages
5. Natural languages
Let us look at each of these categories
1. Machine languages
Humans do not like to deal with numbers alone; they prefer letters and words also. Machine
language consists of numbers. Each type of computer has its own machine language. This is the
lowest level of language. It represents data and program instructions as 1s and 0s- the binary digits
corresponding to the on and off electrical states in the computer. During the early days of computing,
programmers used rudimentary systems for combining numbers to represent instructions such as
add or compare. These programs are not convenient for people to read and use, and the industry
quickly moved to develop assembly languages.
2. Assembly languages
Assembly languages are considered to be very low level languages. They are not as convenient to
use as the more recent languages. However, at the time when they were developed, they were
considered as a great leap forward. To replace the 1s and 0s used in machine language, the
assembly languages use mnemonic codes. Mnemonic codes are abbreviations that are easy to
remember: A for add, C for compare, MP for Multiply and so on. Although these codes are not
English words, they were better accepted than numbers (0s and 1s) alone. Just like machine
language, each type of computer has its own assembly language.
The programmer who uses an assembly language requires a translator to convert the assembly
language program into machine language. A translator is required because machine language is the
only language that the computer can actually execute. The translator is an assembler program,
which is also referred to as an assembler. It takes the programs written in assembly language and
converts them into machine language. Programmers need not worry about the translating aspect,
they only need to write programs in assembly language.
Although assembly languages represent a step forward, they still have many disadvantages. A key
disadvantage is that assembly language is detailed to the extreme, making assembly language
programming repetitive, error prone and tedious.
3. High-Level Languages
The widespread use of high-level languages in the early 1960's transformed programming into
something quite different from what it had been. Programs were written in an English-like manner,
thus making them easier and more convenient to use. Using high-level languages, a programmer
can accomplish more with less effort, and programs can now take care of much more complex tasks.
These so-called third generation languages spurred a great increase in data processing that
characterized the 1960's and 1970's. During that period, the number of mainframes in use increased
from hundreds to tens of thousands.
A translator is used to translate the symbolic statements of a high level language into computer
executable machine language. This translator is called a compiler. There are many compilers for
each language and one for each type of computer. For example, it is necessary to have a COBOL
compiler for each type of computer on which COBOL programs are to be run. A program can be
compiled to different machine language versions on different machines. The source program itself,
that is, the COBOL version is essentially identical on each machine.
Some languages are used to serve a specific purpose, such as creating graphics or controlling
industrial robots. Many languages are extraordinarily flexible and are considered to be generalpurpose languages. In the past, the majority of programming applications were written in BASIC,
COBOL or FORTRAN. All of them are general purpose languages.
4. Very High-Level Languages
Very high-level languages are often known by their generation number. They are called fourthgeneration languages or 4GLs. Fourth-generation languages are beneficial because:
I.They are result-oriented; they emphasize "what" instead of "how".
II.They improve productivity because programs are easy to write and modify.
III.They can be used with minimum training by both programmers and non-programmers.
IV.They shield users from needing an awareness of program structure and hardware.
5. Natural Languages
The word "natural" has become very popular in computing circles. Fifth generation languages are
often called natural languages because of their resemblance to the "natural" spoken English
language. Instead of being forced to key correct commands and data names in correct order, a
manager tells the computer what to do by keying in their own words.
Choosing a Language
In a work environment, the manager may decide that everyone in the project will use a
certain language.
We may choose a language based on its suitability or criteria. For example, COBOL will be
the best option for a business program that handles large files.
We may be limited by the availability of languages. Not all languages are available on all
computers and in all installations.
The language may be limited to the expertise of a programmer. The program may have to be
written in a language that the available programmer knows.