Subject Name: Principles of Programming Languages
Subject Name: Principles of Programming Languages
Unit 1:
Language Evaluation Criteria
Readability is the ease of which programs can be read and understood and can be directly related to:
o The overall simplicity, which can be determined by number of basic components and whether it
has one or more ways to accomplish a particular operation
o The orthogonality, which is the degree to which a set of primitive constructs can be combined
to build the control and data structures of the language
o The number of control statements in a language
o The number of data types and structures
o The syntax or form of the elements of a language. Three types of syntax affect readability:
identifier forms, special words, and form and meaning
Writability is a measure of how easily a language can be used to create programs for a chosen problem
domain and can be directly related to:
o Simplicity and orthogonality (defined in readability)
o Support for abstraction, which is the ability to define and use complicated structures or
operations in a way that allows many details to be ignored
o Expressivity, which is when a language has a convenient way of specifying computations
Reliability is when a language performs to its specifications under all conditions and is directly related
to:
o Type checking, which is simply testing for type errors in a program either by the compiler or
run-time
o Exception handling, which is the ability of a program to intercept run-time errors, take
corrective action, and then continue on
o Aliasing, which is having two or more distinct referencing methods or names for the same
memory location
o Readability and Writability
Language Categories
Imperative – based on the von Neumann architecture
Functional – based on mathematical functions
Logic – rule based
Object oriented – object based
Programming paradigms
Programming paradigms are a way to classify programming languages based on their features. Languages can
be classified into multiple paradigms.
Imperative programming in which the program is built from one or more procedures (also termed
subroutines or functions). The concept of imperative programming is
“First do this and next do that”
Characteristics of imperative programming:
Discipline and idea
o Digital hardware technology and the ideas of Von Neumann
Incremental change of the program state as a function of time.
Execution of computational steps in an order governed by control structures
o The steps for commands
Straightforward abstractions of the way a traditional Von Neumann computer works
Similar to descriptions of everyday routines, such as food recipes and car repair
Typical commands offered by imperative languages
o Assignment, IO, procedure calls
Language representatives
o Fortran, Algol, Pascal, Basic, C
The natural abstraction is the procedure
o Abstracts one or more actions to a procedure, which can be called as a single command.
o "Procedural programming"
The object-oriented paradigm is probably the conceptual anchoring of the paradigm. An object-oriented
program is constructed with the outset in concepts, which are important in the problem domain of interest. In
that way, all the necessary technicalities of programming come in second row. The basic concept of OO is
“Send messages between objects to simulate the temporal evolution of a set of real world phenomena”
Characteristics of Object Oriented Programming:
Discipline and idea
o The theory of concepts, and models of human interaction with real world phenomena
Data as well as operations are encapsulated in objects
Information hiding is used to protect internal properties of an object
Objects interact by means of message passing
o A metaphor for applying an operation on an object
In most object-oriented languages objects are grouped in classes
o Objects in classes are similar enough to allow programming of the classes, as opposed to
programming of the individual objects
o Classes represent concepts whereas objects represent phenomena
Classes are organized in inheritance hierarchies
o Provides for class extension or specialization
Functional programming is in many respects a simpler and more clean programming paradigm than the
imperative one. The reason is that the paradigm originates from a purely mathematical discipline: the theory
of functions. The imperative paradigm is rooted in the key technological ideas of the digital computer, which
are more complicated, and less 'clean' than mathematical function theory. The basic concept of functional
programming is
“Evaluate an expression and use the resulting value for something”
Characteristics of functional programming:
Discipline and idea
o Mathematics and the theory of functions
The values produced are non-mutable
o Impossible to change any constituent of a composite value
o As a remedy, it is possible to make a revised copy of composite value
A temporal
o Time only plays a minor role compared to the imperative paradigm
Applicative
o All computations are done by applying (calling) functions
The natural abstraction is the function
o Abstracts a single expression to a function which can be evaluated as an expression
Functions are first class values
o Functions are full-fledged data just like numbers, lists, ...
Fits well with computations driven by needs
o Opens a new world of possibilities
The logic paradigm is dramatically different from the other three main programming paradigms. The logic
paradigm fits extremely well when applied in problem domains that deal with the extraction of knowledge
from basic facts and relations. The logical paradigm seems less natural in the more general areas of
computation. The basic concept is
"Answer a question via search for a solution"
Characteristics of the logic programming paradigm:
Discipline and idea
o Automatic proofs within artificial intelligence
Based on axioms, inference rules, and queries.
Program execution becomes a systematic search in a set of facts, making use of a set of inference rules