What is
Programming?
How do we write a
Program?
What is a Programming Language?
What is a Computer?
What is ASP Active Server
Page? What
is Virtual Campus?
need any help
please e-mail me
|
|
Computer
What Is a Programming Language?
In the computer, all data, whatever its form, is stored and used in binary codes, strings of
1s and 0s. When computers were first developed, the only programming language available was the
primitive instruction set built into each machine, the machine language, or machine code.
-------------------------------------------------------------------------------------
Machine Language The language, made up of binary-coded instructions, that is used directly by
the computer.
-------------------------------------------------------------------------------------
Even though most computers perform the same kinds of operations, their designers choose
different sets of binary codes for each instruction. So the machine code for one computer is
not the same as for another.
When programmers used machine language for programming, they had to enter the binary codes
for the various instructions, a tedious process that was prone to error. Moreover, their
programs were difficult to read and modify. In time assembly languages were developed to make
the programmer's job easier.
-------------------------------------------------------------------------------------
Assembly Language A low-level programming language in which a mnemonic is used to represent
each of the machine language instructions for a particular computer.
-------------------------------------------------------------------------------------
Instructions in an assembly language are in an easy-to-remember form called a mnemonic
(pronounced "ni-'man-ik"). Typical instructions for addition and subtraction might look like
this:
Assembly Language |
Machine Language |
ADD |
100101 |
SUB |
010011 |
The only problem with assembly languages was that instructions written in them could not be
executed directly by computers. So a program called an assembler was written to translate the
instructions written in assembly language into machine code.
-------------------------------------------------------------------------------------
Assembler A program that translates an assembly language program into
machine code.
-------------------------------------------------------------------------------------
The assembler was a step in the right direction, but programmers still were forced to think in
terms of individual machine instructions. Eventually high-level programming
languages were developed. These languages are easier to use than assembly languages
or machine code because they are closer to English and other natural language.
Programs in high-level languages (Pascal, FORTRAN, COBOL, Modula-2, and Ada, for example)
must be translated into machine language by a program called a compiler. If you write a
program in a high-level language, you can run it on any computer that has the appropriate
compiler. This is because most high-level languages are standardized; that is, an official
description of them exists.
-------------------------------------------------------------------------------------
Compiler A program that translates a high-level language into machine code.
-------------------------------------------------------------------------------------
The International Standards Organization (ISO) established an official description of Pascal
in 1981. Whenever a program is written according to the ISO standard for Pascal, it can be
executed by any computer with a compiler that also adheres to the ISO standard. Unfortunately
not all compilers adhere strictly to that standard; for one reason or another, some recognize
slightly different versions of the Pascal language. Throughout this book, we use the ISO
standard for Pascal unless we specifically say otherwise. If something we tell you doesn't
seem to work on your computer, check to see if its compiler differs from the standard.
A program in a high-level language is called a source program. To the compiler, a source
program is just input data. It translates the source program into a machine language program
called an object program. Some compilers also output a listing—a copy of the
program with error messages and other information inserted.
-------------------------------------------------------------------------------------
Source Program A program written in a high-level programming language.
Object Program The
machine language version of a source program.
-------------------------------------------------------------------------------------
Notice in that compilation and execution are two distinct processes. During
compilation, the computer runs the compiler program. During execution, the object
program replaces the compiler program in the computer's memory. The computer then runs the
object program, doing whatever the program instructs it to do.
The instructions in a programming language reflect the functions a computer can actually
perform:
• A computer can transfer data from one place to another.
• A computer can input data from an input device (a keyboard, for example) and output data to an output device (a screen, for example).
• A computer can store data in and retrieve data from its memory and secondary storage.
• A computer can compare two data values for equality or inequality. • A computer can perform arithmetic operations (addition and subtraction, for example).
Programming languages require that we use certain structures to express algorithms
as programs. There are four basic ways of structuring statements (instructions) in Pascal and
other languages: sequentially, conditionally, repetitively, and procedurally.
A sequence is a series of statements that are executed one after another. Selection, the
conditional structure, executes different statements depending on certain conditions. The
repetitive structure, the loop, repeats statements while certain conditions are met. And the
procedure allows us to structure a program by breaking it into smaller subprograms.
Assume you're driving a car. Going down a straight stretch of road is like following a
sequence of instructions. When you come to a fork in the road, you must decide which way to go
and then take one or the other branch of the fork. This is what the computer does when it
encounters a selection structure (sometimes called a branch or decision) in a
program. Sometimes you have to go around the block several times to find a place to park. The computer
does the same sort of thing when it encounters a loop in a program.
A procedure is a process that consists of multiple steps. Every day, for example, you
follow a procedure to get from home to work. It makes sense, then, for someone to give you
directions to a meeting by saying, "Go to the office and then go four blocks west"—without
repeating all the steps you have to take to get to the office. Procedures allow us to write
parts of our programs separately and then assemble them into final form. They can greatly
simplify the task of writing large programs.
|
|
Ada Lovelace
Charles Babbage
George Boole
Blaise Pascal
Admiral Grace Murry Hopper
Niklaus Wirth
Title Goes Here
|