Programming Languages: Foundations of Computer Science à Cengage Learning
Programming Languages: Foundations of Computer Science à Cengage Learning
Programming
Languages
Foundations of Computer Science ã Cengage Learning 1
EVOLUTION
To write a program for a computer, we must use a computer
language. A computer language is a set of predefined words that
are combined into a program according to predefined rules
(syntax). Over the years, computer languages have evolved from
machine language to high-level languages.
machine language
In the earliest days of computers, the only programming languages
available were machine languages. Each computer had its own
machine language, which was made of streams of 0s and 1s.
Note : The only language understood by a computer is machine
language. 2
Assembly languages
3
High-level languages
Although assembly languages greatly improved programming
efficiency, they still required programmers to concentrate on the
hardware they were using. Working with symbolic languages was
also very tedious, because each machine instruction had to be
individually coded. The desire to improve programmer efficiency
and to change the focus from the computer to the problem being
solved led to the development of high-level languages.
Over the years, various languages, most notably BASIC,
COBOL, Pascal, Ada, C, C++ and Java, were developed.
4
TRANSLATION
Programs today are normally written in one of the high-level
languages. To run the program on a computer, the program
needs to be translated into the machine language of the
computer on which it will run. The program in a high-level
language is called the source program. The translated
program in machine language is called the object program.
Two methods are used for translation:
1. Compilation : A compiler normally translates the whole
source program into the object program.
2. Interpretation : Interpretation refers to the process of
translating each line of the source program into the
corresponding line of the object program and executing
the line. 5
PROGRAMMING PARADIGMS
Today, computer languages are categorized according to
the approach they use to solve a problem. A paradigm,
therefore, is a way in which a computer language looks at
the problem to be solved. We divide computer languages
into four paradigms:
1. Procedural.
2. object-oriented.
3. functional.
4. declarative.
6
7
COMMON CONCEPTS
In this section we conduct a quick navigation through some
procedural languages to find common concepts.
1. Identifiers: it is the name of objects.
2. Data types : defines a set of values and a set of
operations that can be applied to those values.
3. Variables : are names for memory locations.
4. Literal : is a predetermined value used in a program(π).
5. Constant, like a variable, is a named location that can
store a value, but the value cannot be changed after it
has been defined at the beginning of the program
6. Inputs and Outputs
7. Expressions ; is a sequence of operands and operators
that reduces to a single value.
8. Statements.
9. Subprograms. 8
Structured programming strongly recommends the use of the
three types of control statements: sequence, selection and
repetition