Topic 1: Introduction: Overview of Programming Languages

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

TOPIC 1: INTRODUCTION

Overview of Programming Languages


Dozens of programming languages are being used daily in the universities, research laboratories and
industries. All software are written in some programming languages. The purpose of this course is to
introduce the basic principles of programming languages so that you can develop an appreciation for the
benefits and limitations of the different programming languages. You will experience programming in
four major programming paradigms so that you will be in a much better position to choose a particular
programming paradigm to solve programming problems.

Programming Language
Programming Languages are notations for describing computations to people and to machines. All the
software running on all computers was written in some programming languages.

Three Concepts of Programming Language


Computation Machine readability Human readability
Computation is any process that For a language to be machine- It requires that a programming
can be carried out by a computer readable, it must have a simple language provide abstractions of
enough structure to allow for the actions of computers that
efficient translation are easy to understand, even by
persons not completely familiar
with the underlying details of the
machine
Computation includes all kinds of Machine readability is ensured Programming languages tend to
computer operations, including by restricting the structure of a resemble natural languages
data manipulation, text programming language to
processing & information context-free languages
storage & retrieval

Three Levels of Programming Languages


programming language that uses English and
High-Level Languages
mathematical symbols
Low-Level Languages assembly language

Machine Language machine code

Abstractions in Programming Languages


Abstraction plays essential role in making programs easier for people to read. Common abstractions in
provide express computation to programming languages.
Two Categories of Abstractions
Data abstraction Control abstraction
Data abstractions abstract properties of the data, It abstracts properties of the transfer of control,
such as character strings, numbers or search trees, that is the modification of the execution path of a
which is the subject of computation program based on the situation at hand
Examples of control abstractions are loops,
conditional statements, and procedure calls.

Programming language abstractions fall into two general categories: data abstraction and control
abstraction. Data abstractions simplify for human users the behavior and attributes of data, such as
numbers, character strings, and search trees. Control abstractions simplify properties of the transfer of
control, that is, the modification of the execution path of a program based on the situation at hand.
Examples of control abstractions are loops, conditional statements, and procedure calls.

Three Levels of Abstractions


Basic Abstractions Structured Abstractions Unit Abstractions
Basic abstractions collect the Structured abstractions collect Unit abstractions collect large-
most localized machine intermediate information about scale information in a program.
information the structure of a program

Basic Data Abstractions Structured Data Abstractions Unit Data Abstractions


//DECLARATION //DECLARATION //DECLARATION
int integer = 1; int array [10]; Structure struc [10]; //C @ C++
Object [] objectName = new
Object [10]; //JAVA

Basic Control Abstractions Structured Control Abstractions Unit Control Abstractions


Typical basic control abstractions Structured control abstractions Control can also be abstracted to
are those statements in a divide a program into groups of include a collection of
language that combine a few instructions that are nested procedures that provide logically
machine instructions into an within tests that govern their related services to other parts of
abstract statement that is easier execution. They, thus, help the a program and that form a unit,
to understand than the machine programmer to express the logic or stand-alone, part of the
instructions. We have already of the primary control structures program.
mentioned the algebraic of sequencing, selection, and Java has mechanisms for
notation of the arithmetic and iteration (loops). At the machine declaring threads (separately
assignment expressions level, the processor executes a executed control paths within
sequence of instructions simply the Java system) and processes
by advancing a program counter (other programs executing
through the instructions outside the Java system). Ada
memory addresses. Selection provides the task mechanism for
and iteration are accomplished parallel execution.
by the use of branch instructions
to memory locations other than
the next one.
//PROCESS //PROCESS //DECLARATION
sum = value1 + value2; if(maximum > minimum) Structure struc [10]; //C @ C++
//todo something Object [] objectName = new
Object [10]; //JAVA
for(int x = 1; x < 10; x++)
//todo something

Computational Paradigms
There are 4 main programming paradigms:

1. The Imperative Paradigm


2. The Functional Paradigm
3. The Logical Paradigm
4. The Object-Oriented Paradigm

Imperative Paradigm
First do this and next do that

This short phrase describes the imperative paradigm, where the basic idea is the command, which has a
measurable effect on the program state. The order of the commands is also important. Sometimes is
also referred as the procedural programming or structured programming. Data and operations on the
data are separated; you have to send data to procedures and functions.

Functional Paradigm
Evaluate an expression and use the resulting value for something

Functional paradigm originates from a purely mathematical discipline.

Logical Paradigm
Answer a question via search for a solution

Logical paradigm is based on axioms, inference rules and queries. The logical paradigm fits extremely
well when applied in problem domains that deal with the extraction of knowledge from basic facts and
relations.

Object-Oriented Paradigm
Send messages between objects to simulate the temporal evolution of a set of real world phenomena

The object oriented paradigm has gained great popularity. Combines the power of procedural languages
with an added dimension that provides more flexibility, modularity, clarity, and reusability through class
encapsulation, class inheritance and dynamic binding. Data and operations are placed within a single
entity called an object.
Language Definition
Language definition can be loosely divided into two parts: syntax, or structure, and semantics, or
meaning. Syntax and semantics are closely related. Semantic should follow directly from syntax (what
the statement is meant to accomplish).

Language Syntax
The formal rule of how expressions are written or arranged in a programming language is called the
syntax of that language.

Language Semantics
Its semantics is the meaning of those expression, statements, and program units

Language Translation
For a programming language to be useful, it must have a translatorthat is, a program that accepts
other programs written in the language in question and that either executes them directly or transforms
them into a form suitable for execution.

Figure 1.1: The Interpretation Process

A translator that executes a program directly is called an interpreter.

Figure 1.2: The Compilation Process

A translator that produces an equivalent program in a form suitable for execution is called a compiler.

Language Design
A successful programming language should facilitate:
1. Efficiency Abstractions
2. Simplicity Complexity Control
3. Expressiveness Readability

Readability
It is a challenge of programming language design to achieve the power, expressiveness &
comprehensibility that human readability requires while at the same time retaining the precision &
simplicity that is needed for machine translation

Abstractions
A successful programming language has facilities for the:

1. Natural expression of the structure of data (data abstraction)


2. Structure of the computational process for the solution of a problem (control abstraction)
A Brief History

Figure 1.3: Dates and Ancestry of Major Programming Languages.

You might also like