Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
132 views

1-Theory of Programming Languages - Introduction

This document discusses the reasons for studying theory of programming languages. It covers increased capacity to express ideas, improved background for choosing languages, increased ability to learn new languages, and better understanding of implementation significance. It also covers programming domains like scientific applications, business applications, artificial intelligence, and web software. Finally, it discusses language evaluation criteria.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views

1-Theory of Programming Languages - Introduction

This document discusses the reasons for studying theory of programming languages. It covers increased capacity to express ideas, improved background for choosing languages, increased ability to learn new languages, and better understanding of implementation significance. It also covers programming domains like scientific applications, business applications, artificial intelligence, and web software. Finally, it discusses language evaluation criteria.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Theory of Programming Languages Fall, 2020

Theory of Programming
Languages
Riphah Institute for Computing and
Applied Sciences
Dr. Ayesha Kashif

▪ Reasons for Studying Theory of Programming


Languages
▪ Increased capacity to express ideas
▪ Improved background for choosing appropriate
languages
▪ Increased ability to learn new languages
▪ Better understanding of the significance of
implementation
▪ Programming Domains
▪ Language Evaluation Criteria

Dr. Ayesha Kashif -- Riphah Int. Univ 1


Theory of Programming Languages Fall, 2020

Reasons for Studying Programming Language Concepts


▪ Increased capacity to express ideas
▪ The language in which programmers develop software places
limits on the kinds of control structures, data structures, and
abstractions they can use; thus, the forms of algorithms they can
construct are likewise limited.
▪ Awareness of a wider variety of programming language features
can reduce such limitations in software development.
▪ Programmers can increase the range of their software
development thought processes by learning new language
constructs.

Reasons for Studying Programming Language Concepts


▪ Increased capacity to express ideas
▪ the study of programming language concepts builds an
appreciation for valuable language features and constructs and
▪ encourages to use them, even when the language they are using
does not directly support such features and constructs.
▪ For example, a C programmer who had learned the structure and
uses of associative arrays in Perl might design structures that
simulate associative arrays in that language.

Dr. Ayesha Kashif -- Riphah Int. Univ 2


Theory of Programming Languages Fall, 2020

Reasons for Studying Programming Language Concepts


▪ Improved background for choosing appropriate
languages
▪ many programmers, when given a choice of languages for a
new project, use the language with which they are most
familiar, even if it is poorly suited for the project at hand.
▪ If these programmers were familiar with a wider range of
languages and language constructs, they would be better
able to choose the language with the features that best
address the problem.

Reasons for Studying Programming Language Concepts


▪ Increased ability to learn new languages
▪ The process of learning a new programming language can
be lengthy and difficult, especially for someone who is
comfortable with only one or two languages and has never
examined programming language concepts in general.
▪ Once a thorough understanding of the fundamental
concepts of languages is acquired, it becomes far easier to
see how these concepts are incorporated into the design of
the language being learned.
▪ For example, programmers who understand the concepts of
object-oriented programming will have a much easier time
learning Ruby than those who have never used those
concepts.

Dr. Ayesha Kashif -- Riphah Int. Univ 3


Theory of Programming Languages Fall, 2020

Reasons for Studying Programming Language Concepts


▪ Better understanding of the significance of
implementation
▪ In some cases, an understanding of implementation issues
leads to an understanding of why languages are designed
the way they are.
▪ For example, programmers who know little about the
complexity of the implementation of subprogram calls
often do not realize that:
▪ a small subprogram that is frequently called can be a highly
inefficient design choice.

▪ Reasons for Studying Theory of Programming


Languages
▪ Programming Domains
▪ Scientific Applications
▪ Business Applications
▪ Artificial Intelligence
▪ Web Software
▪ Language Evaluation Criteria

Dr. Ayesha Kashif -- Riphah Int. Univ 4


Theory of Programming Languages Fall, 2020

Programming Domains
▪ Scientific Applications
▪ An application that simulates real-world activities using
mathematics, such as numerical weather prediction,
computational fluid dynamics, computational physics, and
computational chemistry etc.
▪ The first language for scientific applications was Fortran.
ALGOL 60 and most of its descendants were also intended
to be used in this area, although they were designed to be
used in related areas as well.
▪ No subsequent language is significantly better than Fortran,
which explains why Fortran is still used

Programming Domains
▪ Business Applications
▪ Special computers were developed for business applications,
along with special languages.
▪ The first successful high-Level language for business was COBOL
(Common Business-Oriented Language). It probably still is the
most commonly used language for these applications.
▪ Business languages are characterized by facilities for producing
▪ elaborate reports,
▪ precise ways of describing and storing decimal numbers and
character data, and
▪ the ability to specify decimal arithmetic operations.

10

Dr. Ayesha Kashif -- Riphah Int. Univ 5


Theory of Programming Languages Fall, 2020

Programming Domains
▪ Artificial Intelligence
▪ Artificial intelligence (AI) is a broad area of computer
applications characterized by the use of symbolic rather than
numeric computations.
▪ Symbolic computation means that symbols, consisting of names
rather than numbers, are manipulated.
▪ The particular form of symbolic logic that is used for logic
programming is called predicate calculus

▪ The following are examples of compound


propositions:

11

Programming Domains
▪ Artificial Intelligence
▪ Also, symbolic computation is more conveniently done with
linked lists of data rather than arrays.
▪ This kind of programming sometimes requires more
flexibility than other programming domains.
▪ For example, in some AI applications the ability to create
and execute code segments during execution is convenient.
▪ The first widely used programming language developed for
AI applications was the functional language Lisp
▪ An alternative is Logic programming using the Prolog,
language.
▪ More recently, some AI applications have been written in
systems languages such as C.

12

Dr. Ayesha Kashif -- Riphah Int. Univ 6


Theory of Programming Languages Fall, 2020

Programming Domains
▪ Web Software
▪ The World Wide Web is supported by an eclectic collection of
languages, ranging from markup languages, such as HTML,
which is not a programming language, to general-purpose
programming languages, such as Java.
▪ Because of the pervasive need for dynamic Web content, some
computation capability is often included in the technology of
content presentation.
▪ This functionality can be provided by embedding programming
code in an HTML document. Such code is often in the form of a
scripting language, such as JavaScript or PHP

13

▪ Reasons for Studying Programming Language


Concepts
▪ Programming Domains
▪ Language Evaluation Criteria
▪ Readability
▪ Overall Simplicity
▪ Data Types
▪ Syntax Design
▪ Writability
▪ Reliability
▪ Cost

14

Dr. Ayesha Kashif -- Riphah Int. Univ 7


Theory of Programming Languages Fall, 2020

Language Evaluation Criteria


▪ Readability
▪ One of the most important criteria for judging a programming
language is the ease with which programs can be read and
understood.
▪ ease of maintenance is determined in large part by the
readability of programs, readability became an important
measure of the quality of programs and programming languages.
▪ There was a distinct crossover from a focus on machine
orientation to a focus on human orientation.

15

Language Evaluation Criteria


▪ Readability: Overall Simplicity:
Language Constructs
▪ The overall simplicity of a
programming language strongly affects
its readability.
▪ A language with a large number of
basic constructs is more difficult to
learn than one with a smaller number.
E.g. different types of loops, control
structures, brackets etc.
▪ Programmers who must use a large
language often learn a subset of the
language and ignore its other features.

16

Dr. Ayesha Kashif -- Riphah Int. Univ 8


Theory of Programming Languages Fall, 2020

Language Evaluation Criteria


▪ Readability: Overall Simplicity: Feature Multiplicity
▪ A second complicating characteristic of a programming language
is feature multiplicity— that is, having more than one way to
accomplish a particular operation.
▪ For example, in Java, a user can increment a simple integer
variable in four different ways:

17

Language Evaluation Criteria


▪ Readability: Overall Simplicity: Operator Overloading
▪ A third potential problem is operator overloading, in which a
single operator symbol has more than one meaning.
▪ For example, it is clearly acceptable to overload + to use it for
both integer and floating- point addition.
▪ In fact, this overloading simplifies a language by reducing the
number of operators.
▪ However, suppose the programmer defined + used between
single- dimensioned array operands to mean the sum of all
elements of both arrays.
▪ Because the usual meaning of vector addition is quite different
from this, this unusual meaning could confuse both the author
and the program’s readers.

18

Dr. Ayesha Kashif -- Riphah Int. Univ 9


Theory of Programming Languages Fall, 2020

Language Evaluation Criteria


▪ Readability: Data Types
▪ The presence of adequate facilities for defining data
types and data structures in a language is another
significant aid to readability.
▪ For example, suppose a numeric type is used for
an indicator flag because there is no Boolean
type in the language.
▪ In such a language, we might have an
assignment such as the following:
timeOut = 1
▪ The meaning of this statement is unclear,
whereas in a language that includes Boolean
types, we would have the following:
timeOut = true
▪ The meaning of this statement is perfectly clear.

19

Language Evaluation Criteria


▪ Readability: Syntax Design: Special words
▪ syntactic design choices that affect readability:
▪ C and its descendants use braces to specify compound
statements. All of these languages have diminished
readability because statement groups are always
terminated in the same way, which makes it difficult to
determine which group is being ended when an end or
a right brace appears.

20

Dr. Ayesha Kashif -- Riphah Int. Univ 10


Theory of Programming Languages Fall, 2020

Language Evaluation Criteria


▪ Readability: Syntax Design: Special words
▪ Fortran 95 and Ada make this clearer by
using a distinct closing syntax for each type of
statement group. For example, Ada uses end if
to terminate a selection construct and end loop
to terminate a loop construct.
▪ This is an example of the conflict between
simplicity that results in fewer reserved
words, as in Java, and the greater readability
that can result from using more reserved
words, as in Ada.
▪ Fortran (while loop)

21

Language Evaluation Criteria


▪ Readability: Syntax Design: Form and
meaning
▪ Semantics, or meaning, should follow
directly from syntax, or form.
▪ In some cases, this principle is violated
▪ In C, for example, the meaning of the
reserved word static depends on the context
of its appearance.
▪ Static variable:
▪ inside a function, it means the variable is
created at compile time.
▪ outside all functions, it means the variable is
visible only in the file in which its definition
appears

22

Dr. Ayesha Kashif -- Riphah Int. Univ 11


Theory of Programming Languages Fall, 2020

▪ Reasons for Studying Programming Language


Concepts
▪ Programming Domains
▪ Language Evaluation Criteria
▪ Readability
▪ Writability
▪ Simplicity
▪ Orthogonality
▪ Expressivity
▪ Reliability
▪ Cost

23

Language Evaluation Criteria


▪ Writability
▪ Writability is a measure of how easily a
language can be used to create programs for a
chosen problem domain.
▪ It simply is not fair to compare the writability of
two languages in the realm of a particular
application when one was designed for that
application and the other was not.
▪ For example, the writabilities of Visual BASIC
(VB) and C are dramatically different for
creating a program that has a graphical user
interface (GUI), for which VB is ideal.
▪ Their writabilities are also quite different for
writing systems programs, such as an operation
system, for which C was designed.

24

Dr. Ayesha Kashif -- Riphah Int. Univ 12


Theory of Programming Languages Fall, 2020

Language Evaluation Criteria


▪ Writability: Simplicity
▪ If a language has a large number of different constructs,
some programmers might not be familiar with all of them.
This situation can lead to a misuse of some features and a
disuse of others that may be either more elegant or more
efficient, or both, than those that are used.
▪ It may even be possible, to use unknown features
accidentally, with bizarre results.

25

Language Evaluation Criteria


▪ Writability: Orthogonality
▪ A smaller number of primitive constructs and a consistent
set of rules for combining them is much better than simply
having a large number of primitives.

26

Dr. Ayesha Kashif -- Riphah Int. Univ 13


Theory of Programming Languages Fall, 2020

Language Evaluation Criteria


▪ Writability: Orthogonality
▪ A smaller number of primitive constructs and a consistent
set of rules for combining them is much better than simply
having a large number of primitives.

27

Language Evaluation Criteria


▪ Writability: Expressivity
▪ Expressivity in a language can refer to several different
characteristics. It means that there are very powerful
operators that allow a great deal of computation to be
accomplished with a very small program.
▪ More commonly, it means that a language has relatively
convenient, rather than cumbersome, ways of specifying
computations.
▪ For example, in C, the notation count++ is more convenient
and shorter than count = count + 1.

28

Dr. Ayesha Kashif -- Riphah Int. Univ 14


Theory of Programming Languages Fall, 2020

Language Evaluation Criteria


▪ Writability: Expressivity
▪ Also, the and then Boolean operator in Ada is a convenient
way of specifying short- circuit evaluation of a Boolean
expression.

▪ In the example above, G (Dog) is only called when the


pointer Dog is not null, i.e. it actually points to something.
▪ The inclusion of the for statement in Java makes writing
counting loops easier than with the use of while, which is
also possible.

29

▪ Reasons for Studying Programming Language


Concepts
▪ Programming Domains
▪ Language Evaluation Criteria
▪ Readability
▪ Writability
▪ Reliability
▪ Type Checking
▪ Exception handling
▪ Aliasing
▪ Cost

30

Dr. Ayesha Kashif -- Riphah Int. Univ 15


Theory of Programming Languages Fall, 2020

Language Evaluation Criteria


▪ Reliability
▪ A program is said to be reliable if it performs to its
specifications under all conditions.
▪ Reliability: Type Checking
▪ Type checking is simply testing for type errors in a given
program, either by the compiler or during program
execution.
▪ The design of Java requires checks of the types of nearly all
variables and expressions at compile time.
▪ This virtually eliminates type errors at run time in Java
programs.

31

Language Evaluation Criteria


▪ Reliability
▪ A program is said to be reliable if it performs to its
specifications under all conditions.
▪ Reliability: Type Checking
▪ One example of how failure to type check, at either compile time
or run time, has led to countless program errors is the use of
subprogram parameters in the original C language
▪ In this language, the type of an actual parameter in a function
call was not checked to determine whether its type matched that
of the corresponding formal parameter in the function.
▪ An int type variable could be used as an actual parameter in a
call to a function that expected a float type as its formal
parameter, and neither the compiler nor the run-time system
would detect the inconsistency.

32

Dr. Ayesha Kashif -- Riphah Int. Univ 16


Theory of Programming Languages Fall, 2020

Language Evaluation Criteria


▪ Reliability: Exception Handling
▪ The ability of a program to intercept run-time errors, take
corrective measures, and then continue is an obvious aid to
reliability. This language facility is called exception handling.
▪ Reliability: Aliasing
▪ Loosely defined, aliasing is having two or more distinct names in
a program that can be used to access the same memory cell.
▪ Most programming languages allow some kind of aliasing— For
example, two pointers (or references) set to point to the same
variable
▪ In such a program, the programmer must always remember that
changing the value pointed to by one of the two changes the value
referenced by the other.

33

▪ Reasons for Studying Programming Language


Concepts
▪ Programming Domains
▪ Language Evaluation Criteria
▪ Readability
▪ Writability
▪ Reliability
▪ Cost

34

Dr. Ayesha Kashif -- Riphah Int. Univ 17


Theory of Programming Languages Fall, 2020

Language Evaluation Criteria


▪ Cost
▪ The total cost of a programming language is a function of many
of its characteristics.
▪ First, there is the cost of training programmers to use the
language, which is a function of the simplicity and orthogonality
of the language and the experience of the programmers.
▪ Second, there is the cost of writing programs in the language.
This is a function of the writability of the language.
▪ Third, there is the cost of compiling programs in the language.
▪ Fourth, the cost of executing programs written in a language is
greatly influenced by that language’s design.
▪ A language that requires many run- time type checks will
prohibit fast code execution, regardless of the quality of the
compiler.

35

Language Evaluation Criteria


▪ The fifth factor is the cost of the language implementation
system. One of the factors that explains the rapid acceptance of
Java is that free compiler/interpreter systems became available
for it soon after its design was released.
▪ Sixth, there is the cost of poor reliability. If the software fails in a
critical system, such as a nuclear power plant or an X- ray
machine for medical use, the cost could be very high.
▪ The final consideration is the cost of maintaining programs,
which includes both corrections and modifications to add new
functionality.

36

Dr. Ayesha Kashif -- Riphah Int. Univ 18


Theory of Programming Languages Fall, 2020

Language Evaluation Criteria


▪ Other Features

37

References
▪ Robert W. Sebesta-2016- Concepts of
Programming Languages
▪ Michael L. Scott - Programming Language
Pragmatics-Morgan Kaufmann (2015)

38

Dr. Ayesha Kashif -- Riphah Int. Univ 19

You might also like