0% found this document useful (0 votes)
65 views37 pages

CSC 132 - PPL

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views37 pages

CSC 132 - PPL

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

PRINCIPLES OF PROGRAMMING LANGUAGES 1

CSC 132
Syllabus

 Unit – 1: Syntax and Semantics

 Unit – 2: Data, Data Types and Basic Statements

 Unit – 3: Subprograms and its Implementation

 Unit – 4: Object-Orientation, Concurrency, Event Handling

 Unit – 5: Functional Programming Languages (Scheme, ML)

 Unit – 6: Logic Programming Languages (Prolog)


Why Study Programming Languages?

 Increased capacity to express ideas


 Improved background for choosing appropriate language
 Increased ability to learn new languages
 Better understanding of the significance of implementation
 Better use of languages that are already known
 Overall advancement of computing
Programming Domains

 Scientific Applications (Fortran)


 Business Applications (COBOL)
 Artificial Intelligence (LISP, Prolog)
 Systems Programming (C)
 Web Software (HTML, PHP, Java)
Language Evaluation Criteria
 Readability
 Writability
 Reliability
 Cost

Adopted from Concepts of Programming Languages - Sebesta


Readability

 Overall simplicity
 Orthogonality
 Data Types
 Syntax Design
 Special words (while, if etc...)
 Form and meaning (Semantics should follow directly from the syntax. Ex: static has different
meaning based on context in C)
Readability – Overall Simplicity

 A language with more number of basic constructs is more difficult to learn than one with a
smaller number.

 Feature multiplicity (having more than one way to accomplish a particular operation).
 Ex: incrementing by 1

 Operator overloading (ex: using + for adding arrays or difference b/w first elements in the
arrays).

 Too much simplicity makes program less readable (ex: assembly language).
Readability – Orthogonality

 Orthogonality is the ability of combining a small set of primitives to build control and data
structures.

 The more orthogonal the design of a language, more is the simplicity.

 Most orthogonal programming language is ALGOL 68.

 Functional languages offer potentially the greatest overall simplicity (as the same
construct, a function can be used for all operations).
Readability – Orthogonality (cont...)

 IBM mainframe instructions for adding two integers that reside in main memory or
registers:
A reg1, memory_cell
AR reg1, reg2

 VAX minicomputer instruction:


ADDL operand_1, operand_2

 In the above example, VAX instruction is more orthogonal as it supports all four
combinations with single instruction.
Readability – Data Types

 The presence of meaningful data types aids readability.

 If a numeric type is used to indicate Boolean conditions, the statement will be unclear.
Ex: timeOut = 1
Writability

 Simplicity and Orthogonality


 A language with small set of primitives is better than one with a large set of primitives
 Too much orthogonality decreases writability
 Support for Abstraction
 Expressivity
Writability – Support for Abstraction

 Abstraction is the ability to define and use complicated structures or operations in ways
that allow many of the details to be ignored.

 Programming languages can support two types of abstraction: process and data.

 Example for process abstraction is to use a subprogram for sorting that is required several
times in a program.

 Example for data abstraction is a binary tree that stores integer data in its nodes. It is better
to implement a binary tree in C++ or Java using classes rather than in Fortran77 using
pointers and dynamic memory management.
Writability – Expressivity

 Ability of a language that allows a great deal of computation to be accomplished with a


very small program.

 In C, count++ is more convenient than writing count = count + 1.

 Inclusion of for statement in Java makes writing counting loops easier than with the use of
while.
Reliability

 A program is said to be reliable if it performs to its specifications under all conditions.

 Type Checking
 Exception Handling
 Aliasing
 Readability and Writability
Reliability – Type Checking

 Type checking is simply testing for type errors either at compile time or run-time.

 As run-time type checking is expensive, compile time checking is desirable. (Ex: Java)
Reliability – Exception Handling

 Ability of a program to intercept run-time errors and take corrective measures is known as
exception handling.

 Ada, C++, Java and C# provides extensive capabilities for exception handling.
Reliability - Aliasing

 Aliasing is having two or more distinct names that can be used to access the same memory
cell (Ex: Pointers in C and C++).

 Many languages greatly restrict aliasing to increase their reliability.


Cost

 Total cost of a programming language is a function of:


 Cost of training the programmers
 Cost of writing the programs
 Cost of compiling the programs in the language
 Cost of executing programs
 Cost of language implementation system (Ex: JVM)
 Cost of poor reliability
 Cost of maintenance

 Other criteria that can be used to evaluate a programming language are: portability, generality
and well-definedness.
Influences on Language Design

 Computer Architecture
 Programming Design Methodologies
Computer Architecture

 Imperative languages have been designed around the computer architecture called the von
Neumann architecture.

 In this architecture, data and programs are stored in memory and they are executed by the
CPU.

 Central features of imperative languages are variables, which model memory cells;
assignment statements, which are based on the piping operation; and iterative form of
repetition, which is the most efficient way to implement repetition on this architecture.
Computer Architecture (cont...)

Adopted from Concepts of Programming Languages - Sebesta


Programming Design Methodologies

 Intense analysis begun in large part by the structured programming movement in the late
1960s.

 New software development methodologies that emerged as a result of the research in


1970s were called top-down design or stepwise refinement.

 In the late 1970s, a shift from procedure-oriented to data-oriented program design


methodologies began.
Programming Design Methodologies (cont...)

 First language to provide a limited support for data abstraction is SIMULA 67.

 Latest step in the evolution of data-oriented software development, which began in the
early 1980s, is object-oriented design.

 First language to include object-oriented concepts was Smalltalk.


Programming Design Methodologies (cont...)

 Imperative language like Ada 95, C++, Java and C# support object-orientation.

 Functional languages like CLOS and F# also support object-orientation.

 Logic programming language like Prolog++ supports object-orientation.


Language Categories

 Imperative languages
 Object-oriented languages
 Functional languages
 Logical languages
 Visual languages
 Scripting languages
 Markup languages
Language Design Trade-offs

 Reliability vs. Cost of Execution


 Ex: Arrays in Java are more reliable than in C (no bounds checking); whereas cost of execution of
C arrays is less than that of Java.

 Readability vs. Writability


 Ex: APL provides rich set of operators for array operations. This allows to write a complex
computation in less number of lines. But the readability of program decreases. (Daniel
McCracken took four hours to read and understand a four-line APL program)
Implementation Methods

 A language implementation system cannot be the only software on a computer. Requires an


operating system also.

 The operating system and language implementations are layered over the machine
language interface of a computer.
Implementation Methods (cont...)

Adopted from Concepts of Programming Languages - Sebesta


Implementation Methods - Compilation

 Programs can be translated to machine language and be directly executed on the computer.
This is called compiler implementation.

 Very fast program execution.

 Ex: C, C++, COBOL, Ada


Implementation Methods – Compilation
(cont...)

Adopted from Concepts of Programming Languages - Sebesta


Implementation Methods – Compilation (cont...)

 The user and system code together is called a load module or executable image.

 Process of collecting system programs and linking them to user programs is called linking
and loading. This is done by a system program called as linker.

 The speed of connection between a computer’s memory and its processor is known as von
Neumann bottleneck. This is the primary motivation for research and development of
parallel computers.
Implementation Methods – Pure
Interpretation
 Programs are interpreted by another program called an interpreter, with no translation.

 Advantage is easy implementation of many source-level debugging operations.

 Disadvantage is this method is 10 to 100 times slower than compiled systems.

 Statement decoding is the bottleneck of a pure interpreter.


Implementation Methods – Pure Interpretation
(cont...)

Adopted from Concepts of Programming Languages - Sebesta


Implementation Methods – Pure Interpretation
(cont...)
 Another disadvantage is, this method requires more space (for including symbol table
along with source code).

 Ex: Earlier versions of APL, SNOBOL and LISP


Implementation Methods – Hybrid Approach

Adopted from Concepts of Programming Languages - Sebesta


Implementation Methods – Hybrid Approach
(cont...)
 High-level programs are translated to an intermediate language designed to allow easy
interpretation.

 This method is better than pure interpretation as the source language statements are
decoded only once.

 Ex: Perl, Java and .NET


Programming Environments

 A programming environment is a collection of tools used in the development of software.

 UNIX is an older programming environment. GUI versions of UNIX or Solaris CDE,


GNOME and KDE.

 Borland’s JBuilder is an IDE.

 Microsoft’s Visual Studio .NET

 NetBeans

You might also like