anurag.edu.inanurag.edu.in/wp-content/uploads/ppl.doc · web viewintroduction and overview of...
TRANSCRIPT
Department of Computer Science and Engineering
Course Name : Principles of Programming language Course Number : Course Designation : Core Prerequisites : C, C++ & JAVA
III B Tech I Semester
(2015-2016)M.MADHAVI
Associate Professor
SYLLABUS
Unit I
Preliminary Concepts: Reasons for studying, concepts of programming languages, Programming domains, Language Evaluation Criteria, influences on Language design, Language categories, Programming Paradigms Imperative, Object Oriented, functional Programming , Logic Programming .Programming Language ImplementationCompilation and Virtual Machines, programming environments.
Syntax and Semantics: general Problem of describing Syntax and Semantics, formal methods of describing syntax - BNF, EBNF for common programming languages features, parse trees, ambiguous grammars, attribute grammars
Unit II
Data types: Introduction, primitive, character, user defined, array, associative, record, union, pointer and reference types, design and implementation uses related to these types .Names, Variable, concept of binding, type checking, strong typing, type compatibility, named constants, variable initialization.
Expressions and Statements: Arithmetic relational and Boolean expressions, Short circuit evaluation mixed mode assignment, Assignment Statements, Control Structures Statement Level, Compound Statements, Selection, Iteration, Unconditional Statements, guarded commands.
Unit III
Subprograms and Blocks: Fundamentals of sub-programs, Scope and lifetime of variable, static and dynamic scope, Design issues of subprograms and operations, local referencing environments, parameter passing methods, overloaded sub-programs, generic sub-programs, parameters that are sub-program names, design issues for functions user defined overloaded operators, co routines.
Abstract Data types: Abstractions and encapsulation, introductions to data abstraction, design issues, language examples, C++ parameterized ADT, object oriented programming in small talk, C++,Java,C#,Ada95.
Unit IV
Concurrency: Subprogram level concurrency, semaphores, monitors, massage passing, Java threads, C# threads.
Exception handling: Exceptions, exception Propagation, Exception handler in Ada, C++ and Java.
Unit V
Logic Programming Language: Introduction and overview of logic programming, basic elements of prolog, application of logic programming.
Functional Programming Languages: Introduction, fundamentals of FPL, LISP, ML, Haskell, application of Functional Programming Languages and comparison of functional and imperative Languages.
TEXT BOOKS & OTHER REFERENCES
Text Books
1.
Concepts of Programming Languages Robert .W. Sebesta 6/e, Pearson Education.
2.
Programming Languages Louden, Second Edition, Thomson.
Suggested / Reference Books
3.
4.
5.
Websites References
1.
http://freevideolectures.com/University/IIT-Madras/Web-Designing/Subject/Page1
2.
http://en.wikipedia.org/wiki/Programming_language
3.
http://www.learnerstv.com/video/Free-video-Lecture-1950-Computer-Science.html
4.
http://www.openculture.com/freeonlinecourses
5.
http://www.dmoz.org/desc/Computers/Programming/Languages
6.
http://freevideolectures.com/Course/2331/Building-Dynamic-Websites/2
7.
http://www.saylor.org/courses/cs404/rief
Time Table
Room No:
W.E.F:
Class Hour
Time
1
2
3
4
12:20 1:10
LUNCH BREAK
5
6
7
9:00 -09:50
09.50 10:40
10:40 11:30
11:30 12: 20
1:10 2:00
2:00 2:50
2:50 3:40
MON
TUE
WED
THU
FRI
SAT
PROGRAM EDUCATIONAL OBJECTIVES (PEOs)
PEO1
The Graduates are employable as software professionals in reputed industries.
PEO2
The Graduates analyzeproblems by applying the principles of computer science, mathematics and scientific investigation to design and implement industry accepted solutions using latest technologies.
PEO3
The Graduates work productively in supportive and leadership roles on multidisciplinary teams with effective communication and team work skills with high regard to legal and ethical responsibilities.
PEO4
The Graduates embrace lifelong learning to meet ever changing developments in computer science and Engineering.
PROGRAM OUTCOMES (POs)
PO1
An ability to communicate effectively and work on multidisciplinary teams
PO2
An ability to identify, formulate and solve computer system problems with professional and ethical responsibility.
PO3
A recognition of the need for, and an ability to engage in life-long learning to use the latest techniques, skills and modern engineering tools
PO4
The broad education necessary to understand the impact of engineering solutions in a global, economic, environmental and social context
PO5
An ability to apply knowledge of mathematics, science, and computing to analyze, design and implement solutions to the realistic problems.
PO6
An ability to apply suitable process with the understanding of software development practice.
Course Outcomes:
CO1
They will be able to Know the modular and object oriented programming
CO2
They will able to write complier programs
CO3
They will be to know logical and functional programming technique
CO4
They will able to develop concurrency programming
MAPPING OF COURSE OBJECTIVES & COURSE OUT COMES WITH
POs & PEOs
Course Outcomes
POs
PEOs
CO1
PO1
PEO2
CO2
PO5
PEO1
CO3
PO5
PEO1
CO4
PO2
PEO2
COURSE SCHEDULE
Distribution of Hours Unit Wise
Unit
Topic
Chapters
Total No. of Hours
Book1
Book2
I
Reasons for studying, concepts of programming languages, Programming domains
Syntax and Semantics
Ch1,2
Ch3,4,5,6,7
14
II
Data types
Expressions and Statements
Ch8,9
-
14
III
Subprograms and Blocks
Abstract Data types
Ch10, 11
-
13
IV
, Concurrency, Exception handling
Ch12,13
-
12
V
Logic Programming Language,
LISP, ML, Haskell
Ch19,20
-
12
Contact classes for Syllabus coverage
65
Tutorial Classes : 08 ; Online Quiz : 1 per unit
Descriptive Tests : 02 (Before Mid Examination)
Revision classes :1 per unit
Number of Hours / lectures available in this Semester / Year
65
The number of topic in every unit is not the same because of the variation, all the units have an unequal distribution of hours
Lecture Plan
S. No.
Topic
Date of Completion
Unit-1
1
Reasons for studying, concepts of programming languages
TB-1
2
Programming domains
TB-1
3
Language Evaluation Criteria
TB-1
4
Influences on Language design, Language categories
TB-1
5
Programming Paradigms Imperative, Object Oriented
TB-1
6
functional Programming , Logic Programming
TB-1
7
Programming Language Implementation
TB-1
8
programming environments
TB-1
9
General Problem of describing Syntax and Semantics
TB-1
10
Formal methods of describing syntax BNF
TB-1
11
EBNF for common programming languages features
TB-1
12
Parse trees
TB-1
13
Ambiguous grammars
TB-1
14
Attribute grammars
TB-1
Unit-II
TB-1
15
Data types: Introduction, primitive, character
TB-1
16
User defined, array, associative, record
TB-1
17
Union, pointer and reference types
TB-1
18
Design and implementation uses related to these types
TB-1
19
Names, Variable, concept of binding
TB-1
20
Type checking, strong typing, Type compatibility
TB-1
21
Named constants, variable initialization
TB-1
22
Arithmetic and relational expressions
TB-1
23
Boolean expressions
TB-1
24
Short circuit evaluation mixed mode assignment
TB-1
25
Assignment Statements
TB-1
26
Control Structures Statement Level
TB-1
27
Compound Statements, Selection
TB-1
28
Iteration, Unconditional Statements
TB-1
Unit-III
TB-1
29
Fundamentals of sub-programs
TB-1
30
Scope and lifetime of variable, static and dynamic scope
TB-1
31
Design issues of subprograms and operations
TB-1
32
Local referencing environments, Parameter passing methods
TB-1
33
Overloaded sub-programs
TB-1
34
Parameters that are sub-program names,
TB-1
35
generic sub-programs
TB-1
36
Design issues for functions
TB-1
37
Abstractions and encapsulation
TB-1
38
Language examples
TB-1
39
Java, C#, Ada 95, Subprogram level concurrency
TB-1
40
Massage passing, Java threads
TB-1
41
Object oriented programming in small talk
TB-1
42
C++
TB-1
43
C# threads
TB-1
44
C++ parameterized ADT
TB-1
Unit-IV
TB-1
45
semaphores, Monitors
TB-1
46
Exceptions
TB-1
47
Exception handler in Ada
TB-1
48
Exception handler in C++
TB-1
49
exception Propagation
TB-1
50
Exception handler in Java
TB-1
51
Introduction to logic programming
TB-1
52
overview of logic programming
TB-1
53
Basic elements of prolog
TB-1
54
Application of logic programming
TB-1
Unit-V
TB-1
55
Introduction to logic programming
TB-1
56
overview of logic programming
TB-1
57
Basic elements of prolog
TB-1
58
Application of logic programming
TB-1
59
Fundamentals of FPL
TB-1
60
LISP
TB-1
61
ML
TB-1
62
Haskell
TB-1
63
Haskell
TB-1
64
Application of Functional Programming Languages
TB-1
65
Comparison of functional and imperative Languages
TB-1
Date of Unit Completion & Remarks
Unit 1
Date
:
__ / __ / __
Remarks:
________________________________________________________________________
________________________________________________________________________
Unit 2
Date
:
__ / __ / __
Remarks:
________________________________________________________________________
________________________________________________________________________
Unit 3
Date
:
__ / __ / __
Remarks:
________________________________________________________________________
________________________________________________________________________
Unit 4
Date
:
__ / __ / __
Remarks:
________________________________________________________________________
________________________________________________________________________
Unit 5
Date
:
__ / __ / __
Remarks:
________________________________________________________________________
________________________________________________________________________
Unit Wise Assignments (With different Levels of thinking (Blooms Taxonomy))
Note: For every question please mention the level of Blooms taxonomy
Unit 1
1.
Write about linker? Explain the responsibilities of the linker? L1
2.
Explain the different aspects of cost of a programming language? L4
3.
What common programming language statements in your opinion is most deter to readability? L3
4.
Define CFG. State whether CFG is a language generator or recognizer? L1
5.
Explain with an example how operator associativity can be incorporated in grammars?
L4
Unit 2
1.
Define strong typing. Discuss how type checking is enforced in Fortran95, Ada, C, C++, and Java. What do you mean by coercion, how does it effect strongly typed languages? L1
2.
Describe the process of Array initialization? L5
3.
Explain all of the difference between subtypes and derived types? L4
4.
Compare and Contrast union, free union and discriminated union? L4
5.
What are the advantages and disadvantages of allowing mixed-mode arithmetic expressions? L4
6.
Explain the problems associated with Unconditional Branching? L4
7.
List out Errors that can occur in Expression Evaluation? L1
Unit 3
1.
Explain the Various Design issues that are involved in functions? L6
2.
Difference between procedures and functions? L4
3.
What is the primary problem with using semaphores to provide synchronization? L3
4.
In what different places can the definition of a C++ member function appears? L4
5
What is a C++ Name space? What is it purpose? L2
Unit 4
1.
Explain in detail about Exception handling in Ada? L4
Unit 5
1.
Explain the difference between CONS, LIST and APPENED? L4
2.
Write a Lisp function Fib (n) that computes a nth Fibonacci number? L3
Unit Wise Case Studies (With different Levels of thinking (Blooms Taxonomy))
Note: For every Case Study please mention the level of Blooms taxonomy
Unit 1
1.
Was the first high level programming language you learned, implemented within pure interpreter, a hybrid implementation system or a compiler? If yes, justify? L5
2.
Enumerate evaluation criteria of some programming language? L4
3.
Many contemporary languages allows to kinds of comments: one in which delimiters are used both ends (multiple-line comments) and one in which a delimiter marks only the beginning of the comment (one-like comments). Discuss the advantage and disadvantages of each of these with respect to our criteria? L3
4.
= L4
A|B|C
+
|
*
|
()
|
Using the above grammer, show a parse tree and a left most derivation for each of the following statemtns.
1) A=(A+B)*C
2) A=B+C+A
3) A=A*(B+C)
4) A=B*(C*(A+B))
Unit 2
1.
Assume the following Ada program was complied and executed using static scoping rules. What value of x is printed in procedure sub1? Under dynamic scoping rules, what value of x is printed in procedure sub1? L3
procedure main is
x: integer;
procedure sub1 is
begin
put(x)
end;
procedure sub2 is
x:integer;
begin
x:=10
sub1
end;
begin
x:=5;
sub2
end;
2.
Some programming languages are typeless what are the obvious advantages and disadvantages of having no types in a language? L2
3.
Write a c program the does a large number of references to element of two dimensional arrays, using only subscripting write a second program that does the same operations but uses pointers and pointer arithmetic for the storage mapping function to do the array reference. Compare the time efficiency of the two programs. Which of the two programs is likely to be more reliable? Why? L1
4.
Let the function fun is defined as L3
int fun(int *k)
{
*k+=4;
return 3 *(*k)-1;
}
Suppose fun is used as follows:
void main()
{
int i=10,j=10;sum1,sum2;
sum1=(i/2)+fun(&i);
sum2=fun(&j)+(j/2);
What are the values of sum1 and sum2
a) If the operands in the expressions are evaluated left to right?
b) If the operands in the expressions are evaluated right to left?
Unit 3
1.
Consider the following program L4
void swap(int a, int b)
{
int temp;
temp=a;
a=b;
b=temp;
}
void main()
{
int value=2,list[5]={1,3,5,7,9};
swap(value, list[0]);
swap(list[0], list[1]);
swap(value, list[value]);
}
For each of the following parameters passing methods, what are all of the values of the variables value and list after each of the three calls to swap?
a) Pass by value
b) Pass by reference
c) Passed by value-result
2.
What dangers are avoided in Java and C# by having implicit garbage collector, relative to C++? L2
3.
What is the best action a system can take when deadlock is detected? L2
Unit 4
1.
In a language with exception handling facilities, it is common to have more subprograms include an error parameter, which can be set to same value representing ok what advantage does linguistic exception handling facility like that of Ada have over this method? L4
Unit 5
1.
Design the quick sort algorithm in scheme language? L6
2.
Construct the scheme function that removes the last element from a give list? L6
Unit Wise Important Questions (With different Levels of thinking (Blooms Taxonomy))
Note: For every question please mention the level of Blooms taxonomy
Unit 1
1.
Explain in detail various phases in the process of compilation? L4
2.
Give an example of how aliasing deters reliability? L3
3.
Why it is useful for a programmer to have some background in language design? L3
4.
Difference between compilation and interpretation? L4
5.
How can knowledge of programming language characteristics benefit the whole computing community? L2
6.
What role does the symbol table play in a complier? L4
7.
In what fundamental way do operational semantics and denotational semantics differ?
L4
8.
Develop an unambiguous grammar that describes the if statement? L3
9.
Discuss the following? L2
1) Assignment statements
2) Logical pretest loops
10.
In what fundamental way do the operational and denotional semantics differ? L3
Unit 2
1.
Define the following? L1
a) Stack Dynamic
b) Explicit Heap Dynamic
c) Implicit Heap Dynamic
d) Static
2.
Describe how the pointers used in C and C++ with examples? L1
3.
Explain pointers, reference types, design issues of pointers, operations on pointers, pointer problems and implementation of pointer and reference types? L4
4.
Difference between Static and Dynamic strings? L4
5.
How does operand evaluation order interact with functional side effects? L3
6.
Discuss the benefits of operator overloading? L2
7.
Explain in detail multiple selection constructs? L4
8.
Explain about the iteration based Data structures? L4
Unit 3
1.
What are the modes, the conceptual models of transfer, the advantages and disadvantages of pass by value, pass by result, pass by value-result and pass by reference parameter passing methods? L3
2.
Define Shallow and deep binding for referencing environment of subprograms that have been passed as parameter? L1
3.
Explain the considerations for choosing parameter passing methods? L4
4.
Explain, how multi dimensional arrays can passed as arguments in Ada language? L4
Unit 4
1.
Classify the difference Physical and logical concurrency? L3
2.
Outline the three possible levels of concurrency in programs? Explain? L2
3
Write short notes on C# threads? L1
4
Discuss the different states a task can be? Explain? L2
5.
Explain the following with examples? L4
a) Exception handler
b) Disabling an Exception
c) Continuation
6.
Explain detailed compassion of Exception handling capablites of C++ and those of Java? Explain the following with examples? L4
7.
How are Exceptions bound to handlers in C++? L3
Unit 5
1.
Explain L4
a) Common Lisp
b) Haskell
c) ML
2.
Discuss the applications of functional languages? L2
3.
Explain the difference between Imperative and functional languages? L4
4.
Outline the semantics of COND and LET? L2
Unit Wise Multiple Choice Questions for CRT & Competitive Examinations
Unit-1
1. Which of the following is true about system software.
a. The operating system and all programming support tools of a computer systems are collectively known as its
System Software.
b. The Operating System and the hardware tools of computer systems are called as system software.
c. The Operating System and the Macroinstruction interpreter collectively is known as system software.
d. System software is same as application software
2. Which of the following is the widely used programming language developed for Artificial Intelligence Application
a. ALGOL 60
b. LISP
c. FORTRAN
d. COBOL
3. Which is a scripting language developed by Netscape for use in both Web server and browsers. [01M01]
a. Java Script
b. HTML
c. AWK
d. PHP
4. Which of the following is the language developed to produce business reports.
a. RPG
b. GPSS
c. PHP
d. ALGOL
5. Which was the first language for scientific applications
a. ALGOL 60
b. FORTRA$
c. LISP
d. COBOL
6. Which was the first high-level language developed for business purpose. [01S02]
a. ALGOL 60
b. LISP
c. COBOL
d. FORTRAN
7. CGI stands for [01S03]
a. Common Gateway Interface
b. Computer Gateway Interface
d. Common Gateway interchange
8. The Unix Operating System is written almost entirely in _ _ _ _ __ _ Language
a. LISP
b. C
c. C++
d. Java
9. C was developed by _ _ _ _ _ _ _
a. Pascal
b. D.Ritchie
c. N.Writh d. A. Kay
10. List of Commands put in a file is called [01S06]
a. Script
b. Tag
c. Language d. Program
11. Languages designed around the prevalent computer architecture, called the von Neumann architecture are called as
a. Imperative Languages
b. Functional languages
c. Object - oriented Languages d. Improved Languages.
12. The first high level programming language to include pointer variables was _ _ _ _ _
a. Algol-60
b. Ada
c. PL/1
d. Fortran
13. The ability of a program to intercept run-time errors, take corrective measures and then continue execution is called
a. Error mechanics
b. Exception handling
c. Abstraction
d. Orthogonality
14. The first Language to provide even limited supported for data abstraction is [02M02]
a. Smalltalk
b. SIMULA67
c. Prolog++
15. Which of the following is true for abstraction
a. The ability to define and then use complicated structure in way that allow many of the details to be ignored
b. The process of hiding all low-level details from the user c. The ability to acquire properties of other class.
d. The ability of a program to intercept run-time errors.
Unit 2
1. A sentence generation is called a _ _ _ _ _ _ _ _ _ _ _ _ _
a. statement b. token
c. BNF
d. derivation
2. Which of the following is a device that can be used to generate the sentences of a language.
a. Sentence generator
b. Language generator
c. Program generator
d. Language recognizers
3. Which is correct about semantics
a. Rules for writing expressions, statements and program units
b. Meaning of the expression, statement and programs units
c. Protocol to be followed by statements
d. Conditions for writing expressions, statements and program units
4. Which of the following of a programming languages can be described by regular grammar
a. Tokens
b. Lexical units c. Lexemes
d. Syntax
5. Which is a language that is used to describe another language.
a. Terminal language
b. Meta language
c. Imperative language
d. Structural language
6. Which of the following is a natural notation for describing syntax
a. Context free grammar
b. Context sensitive grammars
c. Backus - $aur form
d. Regular grammar
7. Which are called the abstractions in a BNF description
a. $on terminals
b. Lexemes c. Tokens
d. Symbols
8. The syntax of a programming language is the form of its expressions, statements and _ _ _ _ _
a. program units
b. steps
c. functions
d. algorithms
9. For the instruction a = b/2 - 1 { a < 10 } is called as
a. Pre condition
b. Post condition
c. Weakest condition d. strong condition
10. For the instruction x = 2 * y - 3, {y < 0 } is called as
a. Pre condition
b. Post condition
c. Weakest condition d. strong condition
Unit-3
1. _ _ _ _ _ _ _ data type stores the data in BDC notation
a. float
b. double c. int
d. decimal
2. _ _ _ _ _ _ _ _ is one in which the range of possible values can be easily associated with the set of positive integers
a. variable b. data
c. ordinal type
d. constant
3. _ _ _ _ _ _ data type model real numbers, but only as approximations
a. float
b. char c. int
d. string
4. _ _ _ _ _ _ _ data type specifically available in a Language for business applications.
a. float
b. double c. int
d. decimal
5. The variables receive values at _ _ _ _ _ _ _ _ _ _ _ _ _ _
a. compile time
b. run time
c. language design time d. load time
6. The attributes of variables are determined at _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
a. compile time
b. run time
c. language design time d. load time
7. A _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ is a set of objects & a set of operations on those objects, which create, build-up, destroy, modify & pick apart instance of the objects
a. Data type
b. Data valued c. State space d. Environment
8. _ _ _ _ _ _ _ is not primitive data type,
a. float b. char c. int
d. string
9. _ _ _ _ _ _ _ _ _ data type store true or false notation
a. float
b. boolean
c. int
d. char
10. _ _ _ _ _ _ _ type stores values as sequences of characters
a. float
b. boolean c. int
d. string types
Unit- 4
1.Multiple selector statement in C is _ _ _ _ _
a. break
b. switch
c. go to
d. continue
2. _ _ _ _ _ _ _ is a two way selector
a. if
b. if else
c. for
d. while
3. In C Switch-Case statement the default expression type can be _ _ _ _ _ _ _ _ _
a. int
b. float
c. double d. char
4. The following is a Exit controlled loop
a. While
b. do-while
c. for
d. go to
5. In Pascal, after normal termination, loop variable is _ _ _ _ _ _ _ _ _ _
a. Undefined
b. assigned last value c. zero
d. one
6. _ _ _ _ _ _ _ _ _ _ language supports labeled iteration
a. C
b. C++
c. Java
d. Pascal
7. In FORTRAN 90, Loop parameters are evaluated _ _ _ _ _ _
a. only once
b. twice c. thrice
d. every time
8. In Ada 60, Loop parameters are evaluated _ _ _ _ _ _
a. only once b. Twice
c. Thrice
d. Everytime
9. The repeated execution of a statement or compound statement is accomplished by _ _ _ _ _
a. Iteration
b. Selection c. Condition d. Blocking
10. In Pascal, Loop parameters are evaluated _ _ _ _ _ _
a. Only once
b. Twice c. Thrice
d. Every time
University Question Papers
II B.TECH - II SEMESTER EXAMINATIONS, APRIL/MAY, 2011
PRINCIPLES OF PROGRAMMING LANGUAGES
(INFORMATION TECHNOLOGY)
Time: 3hours Max. Marks: 75
Answer any FIVE questions
All Questions Carry Equal Marks
- - -
1. How can knowledge of programming language characteristics benefits the whole computing Community? [15]
2.a) The two mathematical models of language description are generation and recognition. Describe how each can define the syntax of a programming language?
b) Develop an unambiguous grammar that describes the if statement. [8+7]
3.a) Explain all of the difference between subtypes and derived types.
b) Define union, free union and discriminated union? [8+7]
4.a) How does operand evaluation order interact with functional side effect ?
b) How does operand evaluation order interact with function side effects? [8+7]
5.a) Define Shallow and Deep binding for referencing environment of subprograms that Have been passed as parameters.
b) Write about Co routines. [8+7]
6.a) In what different places can the definition of a C++ member function appears?
b) What is a C++ namespace and what is its purpose? [8+7]
7. Explain the following with examples
a) Exception Handler
b) Disabling an exception
c) Continuation
d) Built-in Exception. [15]
8.a) What are the difference between CONS, LIST and APPENED?
b) Write a LISP function Fib(n) that computes nth Fibonacci number. [7+8]
********
II B.TECH - II SEMESTER EXAMINATIONS, APRIL/MAY, 2011
PRINCIPLES OF PROGRAMMING LANGUAGES
(INFORMATION TECHNOLOGY)
Time: 3hours Max. Marks: 75
Answer any FIVE questions
All Questions Carry Equal Marks
- - -
1. What are some features of specific programming languages you know whose rationales are a mystery to you? [15]
2. Write a BNF description of the Boolean expressions of Java, including the three operators &&, || and ! and the relational expressions? [15]
3.a) What are the design issues for character string types?
b) What array initialization feature is available in Ada that is not available in other common imperative languages? [7+8]
4. Write text program in c++, java and c# to determine the scope of a variable declared in a for statement. Specifically the code must determine whether such variable is visible after the body of the for statement. [15]
5.a) What are the different models of parameter passing methods? How are they implemented? Give example for each.
b) What causes a C++ template function to be instantiated? [8+7]
6. Write an analysis of the similarities of and differences between java packages and C++ namespaces? [15]
7. What run-time errors or conditions, if any, an Pascal programs detect and handle? [15]
8. What scoping rule is used in
a) COMMON LISP
b) ML
c) Haskell. [15]
* * * * * *
II B.TECH - II SEMESTER EXAMINATIONS, APRIL/MAY, 2011
PRINCIPLES OF PROGRAMMING LANGUAGES
(INFORMATION TECHNOLOGY)
Time: 3hours Max. Marks: 75
Answer any FIVE questions
All Questions Carry Equal Marks
- - -
1. Many languages distinguish between UPPER CASE and LOWER CASE letters in user-defined names. What are the pros and cons of this design decision? [15]
2.a) Describe the basic concept of denotational semantics?
b) What is the difference between synthesized and inherited attributes? [7+8]
3. What are all of the differences between the enumeration types of C++ and those of java? How does a decimal value waste memory space? [15]
4. Determine whether the narrowing explicit type conversions in two languages you know provide errors messages when a converted value loses its usefulness? [15]
5. What are the modes, the conceptual models of transfer, the advantages and disadvantages of pass by value, pass by result, pass by value - result and pass by - reference parameter- passing methods? [15]
6.a) What are the language design issues for abstract data types?
b) What are the disadvantages of designing an abstract data type to be a pointer? [7+8]
7. Write detailed compassion of the Exception Handling capabilities of C++ and those of JAVA? [15]
8. Define functional form and referential transparency? What data types were parts of the original LISP? [15]
********
II B.TECH - II SEMESTER EXAMINATIONS, APRIL/MAY, 2011
PRINCIPLES OF PROGRAMMING LANGUAGES
(INFORMATION TECHNOLOGY)
Time: 3hours Max. Marks: 75
Answer any FIVE questions
All Questions Carry Equal Marks
- - -
1. Which produces faster Program execution, a Compiler (or) pure interpreter? What role does the symbol table play in a compiler? [15]
2.a) Describe the approach of using axiomatic semantics to convert the correctness of a given program?
b) Convert the following EBNF to BNF
S->A{bA}
A-> a[b]A [7+8]
3. What is the purpose of the ACTION, GOTO table of an LR parser? Explain With Example? [15]
4. Write text program in c++, java and c# to determine the scope of a variable declared in a for statement. Specifically the code must determine whether such variable is visible after the body of the for statement. [15]
5. Define static, fixed stack-dynamic, fixed heap-dynamic and heap-dynamic array. What are the advantages of each? [15]
6.a) What is the primary problem with using semaphores to provide synchronization?
b) Explain the difference between physical and logical concurrency? [8+7]
7. What is root class of all java exception classes? What is pattern class of most java user defined exception classes? [15]
8.a) Write a detail note on functions in ML.
b) Give comparison of Functional and Imperative Languages. [7+8]
II B.TECH - II SEMESTER EXAMINATIONS, APRIL/MAY, 2011
PRINCIPLES OF PROGRAMMING LANGUAGES
(INFORMATION TECHNOLOGY)
Time: 3hours Max. Marks: 75
Answer any FIVE questions
All Questions Carry Equal Marks
- - -
1. How can knowledge of programming language characteristics benefits the whole computing Community? [15]
2.a) The two mathematical models of language description are generation and recognition. Describe how each can define the syntax of a programming language?
b) Develop an unambiguous grammar that describes the if statement. [8+7]
3.a) Explain all of the difference between subtypes and derived types.
b) Define union, free union and discriminated union? [8+7]
4.a) How does operand evaluation order interact with functional side effect ?
b) How does operand evaluation order interact with function side effects? [8+7]
5.a) Define Shallow and Deep binding for referencing environment of subprograms that Have been passed as parameters.
b) Write about Co routines. [8+7]
6.a) In what different places can the definition of a C++ member function appears?
b) What is a C++ namespace and what is its purpose? [8+7]
7. Explain the following with examples
a) Exception Handler
b) Disabling an exception
c) Continuation
d) Built-in Exception. [15]
8.a) What are the difference between CONS, LIST and APPENED?
b) Write a LISP function Fib(n) that computes nth Fibonacci number. [7+8]
********
II B.TECH - II SEMESTER EXAMINATIONS, APRIL/MAY, 2011
PRINCIPLES OF PROGRAMMING LANGUAGES
(INFORMATION TECHNOLOGY)
Time: 3hours Max. Marks: 75
Answer any FIVE questions
All Questions Carry Equal Marks
- - -
1. What are some features of specific programming languages you know whose rationales are a mystery to you? [15]
2. Write a BNF description of the Boolean expressions of Java, including the three operators &&, || and ! and the relational expressions? [15]
3.a) What are the design issues for character string types?
b) What array initialization feature is available in Ada that is not available in other common imperative languages? [7+8]
4. Write text program in c++, java and c# to determine the scope of a variable declared in a for statement. Specifically the code must determine whether such variable is visible after the body of the for statement. [15]
5.a) What are the different models of parameter passing methods? How are they implemented? Give example for each.
b) What causes a C++ template function to be instantiated? [8+7]
6. Write an analysis of the similarities of and differences between java packages and C++ namespaces? [15]
7. What run-time errors or conditions, if any, an Pascal programs detect and handle? [15]
8. What scoping rule is used in
a) COMMON LISP
b) ML
c) Haskell. [15]
* * * * * *
II B.TECH - II SEMESTER EXAMINATIONS, APRIL/MAY, 2011
PRINCIPLES OF PROGRAMMING LANGUAGES
(INFORMATION TECHNOLOGY)
Time: 3hours Max. Marks: 75
Answer any FIVE questions
All Questions Carry Equal Marks
- - -
1. Many languages distinguish between UPPER CASE and LOWER CASE letters in user-defined names. What are the pros and cons of this design decision? [15]
2.a) Describe the basic concept of denotational semantics?
b) What is the difference between synthesized and inherited attributes? [7+8]
3. What are all of the differences between the enumeration types of C++ and those of java? How does a decimal value waste memory space? [15]
4. Determine whether the narrowing explicit type conversions in two languages you know provide errors messages when a converted value loses its usefulness? [15]
5. What are the modes, the conceptual models of transfer, the advantages and disadvantages of pass by value, pass by result, pass by value - result and pass by - reference parameter- passing methods? [15]
6.a) What are the language design issues for abstract data types?
b) What are the disadvantages of designing an abstract data type to be a pointer? [7+8]
7. Write detailed compassion of the Exception Handling capabilities of C++ and those of JAVA? [15]
8. Define functional form and referential transparency? What data types were parts of the original LISP? [15]
********
II B.TECH - II SEMESTER EXAMINATIONS, APRIL/MAY, 2011
PRINCIPLES OF PROGRAMMING LANGUAGES
(INFORMATION TECHNOLOGY)
Time: 3hours Max. Marks: 75
Answer any FIVE questions
All Questions Carry Equal Marks
- - -
1. Which produces faster Program execution, a Compiler (or) pure interpreter? What role does the symbol table play in a compiler? [15]
2.a) Describe the approach of using axiomatic semantics to convert the correctness of a given program?
b) Convert the following EBNF to BNF
S->A{bA}
A-> a[b]A [7+8]
3. What is the purpose of the ACTION, GOTO table of an LR parser? Explain With Example? [15]
4. Write text program in c++, java and c# to determine the scope of a variable declared in a for statement. Specifically the code must determine whether such variable is visible after the body of the for statement. [15]
5. Define static, fixed stack-dynamic, fixed heap-dynamic and heap-dynamic array. What are the advantages of each? [15]
6.a) What is the primary problem with using semaphores to provide synchronization?
b) Explain the difference between physical and logical concurrency? [8+7]
7. What is root class of all java exception classes? What is pattern class of most java user defined exception classes? [15]
8.a) Write a detail note on functions in ML.
b) Give comparison of Functional and Imperative Languages. [7+8]
B.Tech II Year - II Semester Examinations, December-January, 2011-2012
PRINCIPLES OF PROGRAMMING LANGUAGES
(INFORMATION TECHNOLOGY)
Time: 3 hours Max. Marks: 75
Answer any five questions
All questions carry equal marks
---
1.a) What are the advantages and disadvantages of Aliasing.
b) Readability and writability influence the reliability. Comment on it. [15]
2.a) Explain the general problem of describing syntax.
b) Consider the grammar E E+E
E E*E
E i
Using the expression 5+6*7, prove that the grammar is ambiguous. [15]
3.a) Discuss the design issues for pointer types.
b) Define the terms: coercion, type error, strong typing. [15]
4.a) Explain about mixed mode assignment.
b) Every counting loop can be built with a logical loop, but the reverse is not true. Substantiate this statement. [15]
5. What is meant by generic sub program? Explain the support provided by programming languages for generic subprograms. [15]
6.a) What advantages do monitors have over semaphores? Explain.
b) Explain why naming encapsulations are important for developing large programs.
[15]
7. Explain list processing in LISP using scheme functions. Use lucid examples in your explanation. [15]
8. What is exception? Discuss in detail the concept of exception propagation. [15]
********
B.Tech II Year - II Semester Examinations, December-January, 2011-2012
PRINCIPLES OF PROGRAMMING LANGUAGES
(INFORMATION TECHNOLOGY)
Time: 3 hours Max. Marks: 75
Answer any five questions
All questions carry equal marks
- - -
1. Discuss language evaluation criteria and the characteristics that affect them. [15]
2.a) In what way do operational semantics and denotational semantics differ? Explain.
b) Describe the additional features of Extended BNF. [15]
3.a) Discuss the advantages and disadvantages of dynamic scoping.
b) What is a heterogeneous array? Discuss the design issues for arrays. [15]
4. Explain in detail the design issues for arithmetic expressions. [15]
5.a) Describe the three semantic models of parameter passing.
b) What is a parameter profile? Write about subprogram protocol. [15]
6.a) Compare the class entity access controls of C++ and Java.
b) Define race condition
c) What is the purpose of a task-ready queue? [15]
7.a) Explain the procedural abstraction in Python.
b) Discuss the fundamental of functional programming language. [15]
8. Give an overview of logic programming and discuss its applications. [15]
********
B.Tech II Year - II Semester Examinations, December-January, 2011-2012
PRINCIPLES OF PROGRAMMING LANGUAGES
(INFORMATION TECHNOLOGY)
Time: 3 hours Max. Marks: 75
Answer any five questions
All questions carry equal marks
- - -
1. Explain various programming domains. What are your arguments for and against having a single language for all programming domains? [15]
2.a) Discuss the basic concept of Denotational semantics.
b) Show a parse tree and leftmost derivation for the statement: A=(A+B)*C
Given grammar is: =
A/B/C
+ /
* /
() / [15]
3.a) Compare and contrast Static binding with Dynamic binding.
b) Explain various user-defined ordinal types with examples. [15]
4.a) Discuss the problem of operand evaluation order and side effects along with possible solutions.
b) Describe user-located loop control mechanisms. [15]
5.a) Explain the general characteristics of subprograms.
b) What is a co-routine? How do they provide interleaved execution? [15]
6.a) What are the language design requirements for a languages that supports ADTs?
b) How is cooperation synchronization provided for Ada tasks? Explain. [15]
7. Discuss how scheme functions are used to solve the problems in simple list-processing with examples. [15]
8. Explain the basic elements of Prolog with illustrations. [15]
*********
B.Tech II Year - II Semester Examinations, December-January, 2011-2012
PRINCIPLES OF PROGRAMMING LANGUAGES
(INFORMATION TECHNOLOGY)
Time: 3 hours Max. Marks: 75
Answer any five questions
All questions carry equal marks
- - -
1.a) List the potential benefits of studying concepts of programming language.
b) What are the important factors that influence the basic design of programming language? [15]
2. Describe briefly formal language generation mechanisms used to describe the syntax of programming languages. [15]
4.a) Define name type compatibility and structure type compatibility. What are the relative merits of these two?
b) Explain in detail implementation of pointer and reference types. [15]
4.a) Describe coercion in expressions.
b) Explain in detail Dijkstras guarded commands with examples. [15]
5. Explain variety of models that guide the implementation of the three basic parameter transmission modes. [15]
6.a) What dangers are avoided in Java by having implicit garbage collection, relative to C++?
b) Discuss the primary reason for all Java objects have a common ancestor.
c) What is a binary semaphore? Compare it with counting semaphore. [15]
7.a) Explain type inferencing in ML.
b) Discuss the key concepts of scripting language. [15]
8. Discuss various types of exceptions. Explain exception handler in Ada with suitable examples. [15]
B.Tech III-I Semester Examinations, December 2011
PRINCIPLES OF PROGRAMMING LANGUAGES
(COMPUTER SCIENCE AND ENGINEERING)
Time: 3 hours Max. Marks: 80
Answer any five questions
All questions carry equal marks
---
1. A programming language can be compiled or interpreted. Give relative advantages and disadvantages of compilation and interpretation. Give examples of compiled and interpreted languages. [16]
2. How do you describe the meaning of program using operational semantics? Explain with suitable examples and compare it with denotational semantics. [16]
3.a) Describe narrowing and widening conversion.
b) Explain the concept of late binding and early binding. [8+8]
4. Discuss different types of assignment statements. With lucid examples explain mixed mode assignment. [16]
5.a) Discuss the design issues of sub programs.
b) Write about overloaded subprograms.
c) What are coroutines? [16]
6.a) Discuss the Object oriented programming features supported in small talk.
b) What is meant by subprogram level concurrency? Explain. [8+8]
7. What is an exception? Explain exception propagation and handling in C++. [16]
8.a) Write about functions in ML and Haskell.
b) Discuss the data types supported in Python. [8+8]
--ooOoo-- RRCode No: RR310505 SET-1
B.Tech III-I Semester Examinations, December 2011
PRINCIPLES OF PROGRAMMING LANGUAGES
(COMPUTER SCIENCE AND ENGINEERING)
Time: 3 hours Max. Marks: 80
Answer any five questions
All questions carry equal marks
---
1.a) Describe narrowing and widening conversion.
b) Explain the concept of late binding and early binding. [8+8]
2. Discuss different types of assignment statements. With lucid examples explain mixed mode assignment. [16]
3.a) Discuss the design issues of sub programs.
b) Write about overloaded subprograms.
c) What are coroutines? [16]
4.a) Discuss the Object oriented programming features supported in small talk.
b) What is meant by subprogram level concurrency? Explain. [8+8]
5. What is an exception? Explain exception propagation and handling in C++. [16]
6.a) Write about functions in ML and Haskell.
b) Discuss the data types supported in Python. [8+8]
7. A programming language can be compiled or interpreted. Give relative advantages and disadvantages of compilation and interpretation. Give examples of compiled and interpreted languages. [16]
8. How do you describe the meaning of program using operational semantics? Explain with suitable examples and compare it with denotational semantics. [16]
--ooOoo-- RRCode No: RR310505 SET-2
B.Tech III-I Semester Examinations, December 2011
PRINCIPLES OF PROGRAMMING LANGUAGES
(COMPUTER SCIENCE AND ENGINEERING)
Time: 3 hours Max. Marks: 80
Answer any five questions
All questions carry equal marks
---
1.a) Discuss the design issues of sub programs.
b) Write about overloaded subprograms.
c) What are coroutines? [16]
2.a) Discuss the Object oriented programming features supported in small talk.
b) What is meant by subprogram level concurrency? Explain. [8+8]
3. What is an exception? Explain exception propagation and handling in C++. [16]
4.a) Write about functions in ML and Haskell.
b) Discuss the data types supported in Python. [8+8]
5. A programming language can be compiled or interpreted. Give relative advantages and disadvantages of compilation and interpretation. Give examples of compiled and interpreted languages. [16]
6. How do you describe the meaning of program using operational semantics? Explain with suitable examples and compare it with denotational semantics. [16]
7.a) Describe narrowing and widening conversion.
b) Explain the concept of late binding and early binding. [8+8]
8. Discuss different types of assignment statements. With lucid examples explain mixed mode assignment. [16]
--
B.Tech III-I Semester Examinations, December 2011
PRINCIPLES OF PROGRAMMING LANGUAGES
(COMPUTER SCIENCE AND ENGINEERING)
Time: 3 hours Max. Marks: 80
Answer any five questions
All questions carry equal marks
---
1. What is an exception? Explain exception propagation and handling in C++. [16]
2.a) Write about functions in ML and Haskell.
b) Discuss the data types supported in Python. [8+8]
3. A programming language can be compiled or interpreted. Give relative advantages and disadvantages of compilation and interpretation. Give examples of compiled and interpreted languages. [16]
4. How do you describe the meaning of program using operational semantics? Explain with suitable examples and compare it with denotational semantics. [16]
5.a) Describe narrowing and widening conversion.
b) Explain the concept of late binding and early binding. [8+8]
6. Discuss different types of assignment statements. With lucid examples explain mixed mode assignment. [16]
7.a) Discuss the design issues of sub programs.
b) Write about overloaded subprograms.
c) What are coroutines? [16]
8.a) Discuss the Object oriented programming features supported in small talk.
b) What is meant by subprogram level concurrency? Explain. [8+8]
Tutorial Sheet
Unit-I
Topics Revised
Date:
Quick Test Topics
Date:
Case Study Discussed
Date:
Unit-II
Topics Revised
Date:
Quick Test Topics
Date:
Case Study Discussed
Date:
Unit-III
Topics Revised
Date:
Quick Test Topics
Date:
Case Study Discussed
Date:
Unit-IV
Topics Revised
Date:
Quick Test Topics
Date:
Case Study Discussed
Date:
Unit-V
Topics Revised
Date:
Quick Test Topics
Date:
Case Study Discussed
Date:
TOPICS BEYOND SYLLABUS
Unit 1
1.
2.
3.
4.
Unit 2
1.
2.
3.
4.
Unit 3
1.
2.
3.
4.
Unit 4
1.
2.
3.
4.
Unit 5
1.
2.
3.
4.
5.
ASSESMENT OF LEARNING OBJECTIVES AND OUT COMES: DIRECT
Blooms Taxonomy:
LEVEL 1
REMEMBERING
Exhibit memory of previously learned material by recalling facts, terms, basic concepts, and answers
LEVEL 2
UNDERSTANDING
Demonstrate understanding of facts and ideas by organizing, comparing, translating, interpreting, giving descriptions, and stating main ideas.
LEVEL 3
APPLYING
Solve problems to new situations by applying acquired knowledge, facts, techniques and rules in a different way
LEVEL 4
ANALYZING
Examine and break information into parts by identifying motives or causes. Make inferences and find evidence to support generalizations.
LEVEL 5
EVALUATING
Present and defend opinions by making judgments about information, validity of ideas, or quality of work based on a set of criteria.
LEVEL 6
CREATING
Compile information together in a different way by combining elements in a new pattern or proposing alternative solutions.
S.No.
Hall Ticket
Number
I-Internal
Marks
Assignment
Marks
Remarks &
Blooms Taxonomy Assessment
II-Internal
Marks
Assignment
Marks
Remarks &
Blooms Taxonomy Assessment
Avg.
Marks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
ASSESMENT OF LEARNING OBJECTIVES AND OUT COMES: INDIRECT
Blooms Taxonomy:
LEVEL 1
REMEMBERING
Exhibit memory of previously learned material by recalling facts, terms, basic concepts, and answers
LEVEL 2
UNDERSTANDING
Demonstrate understanding of facts and ideas by organizing, comparing, translating, interpreting, giving descriptions, and stating main ideas.
LEVEL 3
APPLYING
Solve problems to new situations by applying acquired knowledge, facts, techniques and rules in a different way
LEVEL 4
ANALYZING
Examine and break information into parts by identifying motives or causes. Make inferences and find evidence to support generalizations.
LEVEL 5
EVALUATING
Present and defend opinions by making judgments about information, validity of ideas, or quality of work based on a set of criteria.
LEVEL 6
CREATING
Compile information together in a different way by combining elements in a new pattern or proposing alternative solutions.
S.N0
Criteria
LEVEL ( Level : 5-Excellent Level :4-Very Good Level :3-Good Level :2-Satisfactory Level : 1-Poor )
1
Oral
Communication
5
Student speaks in phase with the given topic confidently using Audio-Visual aids. Vocabulary is exceptional
4
Student speaking with proper planning, fair usage of Audio-Visual aids. Vocabulary is good
3
Student speaking without proper planning, fair usage of Audio-Visual aids. Vocabulary is not good
2
Student speaks in phase but no synchronization among the talk and Visual Aids.
1
Student speaks vaguely not in phase with the given topic.
2
Writing Skills
5
Proper structuring of the document with relevant subtitles, readability of document is high with correct use of grammar. Work is genuine and not published anywhere else.
4
Information gathered is relevant to the given task. sentences were framed properly with correct use of grammar.
3
Information gathered is relevant to the given task. sentences were framed properly with inappropriate use of grammar
2
Information is gathered without continuity of topic, sentences were not framed properly. Few topics are copied from other documents
1
Information gathered was not relevant to the given task. Content is copied from other documents
3
Social and Ethical Awareness
5
Student identifies most potential ethical or societal issues and provides solutions for them discussing with peers
4
Student identifies most potential ethical or societal issues and provides partial solutions for them discussing with peers
3
Student identifies the societal and ethical issues but tries to provide solutions for them discussing with peers
2
Student identifies the societal and ethical issues but fails to provide any solutions discussing with peers
1
Student makes no attempt in identifying the societal and ethical issues
4
Content Knowledge
5
Student uses appropriate methods, techniques to model and solve the problem accurately
4.
Student uses appropriate methods, techniques to model and solve the problem partially.
3
Student uses appropriate methods to model the problem but attempts to solve the problem
2
Student tries to model the problem and fails to solve the problem
1
Student fails to model the problem and also fails to solve the problem
5
Student Participation
5
Listens carefully to the class and answer the questions confidently
4
Listens carefully to the class and tries to answer questions confidently.
3
Listens carefully to the lecture and attempts to answer the questions
2
Student listens to the class but doesnt attempts to answer the questions
1
Student neither listens to the class nor attempts to answer the questions
6
Technical and analytical Skills
5
The program structure is well organized with appropriate use of technologies and methodology. Code is easy to read and well documented. Student is able to implement the algorithm producing accurate results
4
Program structure is well organized with appropriate use of technologies and methodology. Code is easy to read and not properly documented. Student is able to implement the algorithm providing accurate results.
3
Program structure is well organized with appropriate use of technologies and methodology. Code is quite difficult to read and not properly documented. Student is able to implement the algorithm providing accurate results.
2
Program structure is well organized with usage of appropriate technologies and methodology. Code is difficult to read and not documented properly and not able to execute the program
1
Program structure is not well organized with mistakes in usage of appropriate technologies and methodology. Code is difficult to read and student is not able to execute the program
7
Practical Knowledge
5
Independently able to write programs for any given context to strengthen the concepts covered in theory
4
Independently able to write programs to strengthen the concepts covered in theory
3
Independently able to write programs and able to strengthen the concepts learned in theory
2
Not able to write programs but able to strengthen the concepts learned in theory.
1
Not able to write programs and not able to strengthen the concepts learned in theory
8
Understanding of Engineering core
5
Student uses appropriate methods, techniques to model and solve the problem accurately in the context of multidisciplinary projects
4
Student tries to model the problem and solve the problem in the context of multidisciplinary projects
3
Student tries to model the problem and attempts to solve the problem in the context
of multidisciplinary projects.
2
Student tries to model the problem but fails to solve the problem in the context
of multidisciplinary projects.
1
Student fails to model the problem and also fails to solve the problem in the context
of multidisciplinary projects
CSP Rubric Name & Number:
S.No.
Hall Ticket Number
Rubric Assessment
Blooms Taxonomy Assessment
Remarks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Remedial Classes:
Unit Number
Date Conducted
Topics Revised
Unit-I
Unit-II
Unit-III
Unit-IV
Unit-V
Unit-VI
Unit-VII
Unit-VIII
Add-on Programmes:
1 To conduct lab
Guest Lectures:
1.
2.
3.
4.
Unit Wise lecture Notes:
UNIT-I
Preliminaries Concepts
Topics
1. Reasons for Studying Concepts of Programming Languages
2. Programming Domains
3. Language Evaluation Criteria
4. Influences on Language Design
5. Language Categories
6. Language Design Trade-Offs
7. Implementation Methods
8. Programming Environments
`
Background
Frankly, we didnt have the vaguest idea how the thing [FORTRAN language and compiler] would work out in detail. We struck out simply to optimize the object program, the running time, because most people at that time believed you couldnt do that kind of thing. They believed that machined-coded programs would be so inefficient that it would be impractical for many applications.
-John Backus
Unexpected successes are common the browser is another example of an unexpected success
1.1 Reasons for Studying Concepts of Programming Languages
Increased ability to express ideas
Improved background for choosing appropriate languages
Increased ability to learn new languages
Better understanding of significance of implementation
Overall advancement of computing
1.2 Programming Domains
Scientific applications
Large number of floating point computations
Fortran
Business applications
Produce reports, use decimal numbers and characters
COBOL
Artificial intelligence
Symbols rather than numbers manipulated
LISP
Systems programming
Need efficiency because of continuous use
C
Web Software
Eclectic collection of languages: markup (e.g., XHTML), scripting (e.g., PHP), general-purpose (e.g., Java)
1.3 Language Evaluation Criteria
Readability: the ease with which programs can be read and understood
Writability: the ease with which a language can be used to create programs
Reliability: conformance to specifications (i.e., performs to its specifications)
Cost: the ultimate total cost
Evaluation Criteria: Readability
Overall simplicity
A manageable set of features and constructs
Few feature multiplicity (means of doing the same operation)
Minimal operator overloading
Orthogonality
A relatively small set of primitive constructs can be combined in a relatively small number of ways
Every possible combination is legal
Control statements
The presence of well-known control structures (e.g., while statement)
Data types and structures
The presence of adequate facilities for defining data structures
Syntax considerations
Identifier forms: flexible composition
Special words and methods of forming compound statements
Form and meaning: self-descriptive constructs, meaningful keywords
Evaluation Criteria: Writability
Simplicity and orthogonality
Few constructs, a small number of primitives, a small set of rules for combining them
Support for abstraction
The ability to define and use complex structures or operations in ways that allow details to be ignored
Expressivity
A set of relatively convenient ways of specifying operations
Example: the inclusion of for statement in many modern languages
Evaluation Criteria: Reliability
Type checking
Testing for type errors
Exception handling
Intercept run-time errors and take corrective measures
Aliasing
Presence of two or more distinct referencing methods for the same memory location
Evaluation Criteria: Cost
Training programmers to use language
Writing programs (closeness to particular applications)
Compiling programs
Executing programs
Language implementation system: availability of free compilers
Reliability: poor reliability leads to high costs
Maintaining programs
Evaluation Criteria: Others
Portability
The ease with which programs can be moved from one implementation to another
Generality
The applicability to a wide range of applications
Well-definedness
The completeness and precision of the languages official definition
1.4 Influences on Language Design
Computer Architecture
Languages are developed around the prevalent computer architecture, known as the von Neumann architecture
Programming Methodologies
New software development methodologies (e.g., object-oriented software development) led to new programming paradigms and by extension, new programming languages
Computer Architecture Influence
Well-known computer architecture: Von Neumann
Imperative languages, most dominant, because of von Neumann computers
Data and programs stored in memory
Memory is separate from CPU
Instructions and data are piped from memory to CPU
Basis for imperative languages
Variables model memory cells
Assignment statements model piping
Iteration is efficient
The von Neumann Architecture
Programming Methodologies Influences
1950s and early 1960s: Simple applications; worry about machine efficiency
Late 1960s: People efficiency became important; readability, better control structures
structured programming
top-down design and step-wise refinement
Late 1970s: Process-oriented to data-oriented
data abstraction
Middle 1980s: Object-oriented programming
Data abstraction + inheritance + polymorphism
1.5 Language Categories
Imperative
Central features are variables, assignment statements, and iteration
Examples: C, Pascal
Functional
Main means of making computations is by applying functions to given parameters
Examples: LISP, Scheme
Logic
Rule-based (rules are specified in no particular order)
Example: Prolog
Object-oriented
Data abstraction, inheritance, late binding
Examples: Java, C++
Markup
New; not a programming per se, but used to specify the layout of information in Web documents
Examples: XHTML, XML
1.6 Language Design Trade-Offs
Reliability vs. cost of execution
Conflicting criteria
Example: Java demands all references to array elements be checked for proper indexing but that leads to increased execution costs
Readability vs. writability
Another conflicting criteria
Example: APL provides many powerful operators (and a large number of new symbols), allowing complex computations to be written in a compact program but at the cost of poor readability
Writability (flexibility) vs. reliability
Another conflicting criteria
Example: C++ pointers are powerful and very flexible but not reliably used
1.7 Implementation Methods
Compilation
Programs are translated into machine language
Pure Interpretation
Programs are interpreted by another program known as an interpreter
Hybrid Implementation Systems
A compromise between compilers and pure interpreters
Layered View of Computer
The operating system and language implementation are layered over Machine interface of a computer
Compilation
Translate high-level program (source language) into machine code (machine language)
Slow translation, fast execution
Compilation process has several phases:
lexical analysis: converts characters in the source program into lexical units
syntax analysis: transforms lexical units into parse trees which represent the syntactic structure of program
Semantics analysis: generate intermediate code
code generation: machine code is generated
The Compilation Process
Additional Compilation Terminologies
Load module (executable image): the user and system code together
Linking and loading: the process of collecting system program and linking them to user program
Execution of Machine Code
Fetch-execute-cycle (on a von Neumann architecture)
initialize the program counter
repeat forever
fetch the instruction pointed by the counter
increment the counter
decode the instruction
execute the instruction
end repeat
Von Neumann Bottleneck
Connection speed between a computers memory and its processor determines the speed of a computer
Program instructions often can be executed a lot faster than the above connection speed; the connection speed thus results in a bottleneck
Known as von Neumann bottleneck; it is the primary limiting factor in the speed of computers
Pure Interpretation
No translation
Easier implementation of programs (run-time errors can easily and immediately displayed)
Slower execution (10 to 100 times slower than compiled programs)
Often requires more space
Becoming rare on high-level languages
Significant comeback with some Web scripting languages (e.g., JavaScript)
Hybrid Implementation Systems
A compromise between compilers and pure interpreters
A high-level language program is translated to an intermediate language that allows easy interpretation
Faster than pure interpretation
Examples
Perl programs are partially compiled to detect errors before interpretation
Initial implementations of Java were hybrid; the intermediate form, byte code, provides portability to any machine that has a byte code interpreter and a run-time system (together, these are called Java Virtual Machine)
Just-in-Time Implementation Systems
Initially translate programs to an intermediate language
Then compile intermediate language into machine code
Machine code version is kept for subsequent calls
JIT systems are widely used for Java programs
.NET languages are implemented with a JIT system
Preprocessors
Preprocessor macros (instructions) are commonly used to specify that code from another file is to be included
A preprocessor processes a program immediately before the program is compiled to expand embedded preprocessor macros
A well-known example: C preprocessor
expands #include, #define, and similar macros
Describing Syntax and Semantics
Topics
Introduction
The General Problem of Describing Syntax
Formal Methods of Describing Syntax
Attribute Grammars
Describing the Meanings of Programs: Dynamic Semantics
2.1 Introduction
Syntax: the form or structure of the expressions, statements, and program units
Semantics: the meaning of the expressions, statements, and program units
Syntax and semantics provide a languages definition
o Users of a language definition
Other language designers
Implementers
Programmers (the users of the language)
2.2 The General Problem of Describing Syntax: Terminology
A sentence is a string of characters over some alphabet
A language is a set of sentences
A lexeme is the lowest level syntactic unit of a language (e.g., *, sum, begin)
A token is a category of lexemes (e.g., identifier)
Formal Definition of Languages
Recognizers
A recognition device reads input strings of the language and decides whether the input strings belong to the language
Example: syntax analysis part of a compiler
Detailed discussion in Chapter 4
Generators
A device that generates sentences of a language
One can determine if the syntax of a particular sentence is correct by comparing it to the structure of the generator
2.3 Formal Methods of Describing Syntax
Backus-Naur Form and Context-Free Grammars
Most widely known method for describing programming language syntax
Extended BNF
Improves readability and writability of BNF
Grammars and Recognizers
BNF and Context-Free Grammars
Context-Free Grammars
Developed by Noam Chomsky in the mid-1950s
Language generators, meant to describe the syntax of natural languages
Define a class of languages called context-free languages
Backus-Naur Form (BNF)
Backus-Naur Form (1959)
Invented by John Backus to describe Algol 58
BNF is equivalent to context-free grammars
BNF is ametalanguage used to describe another language
In BNF, abstractions are used to represent classes of syntactic structures--they act like syntactic variables (also called nonterminal symbols)
BNF Fundamentals
Non-terminals: BNF abstractions
Terminals: lexemes and tokens
Grammar: a collection of rules
Examples of BNF rules:
identifier | identifer,
if then
BNF Rules
A rule has a left-hand side (LHS) and a right-hand side (RHS), and consists of terminal and nonterminal symbols
A grammar is a finite nonempty set of rules
An abstraction (or nonterminal symbol) can have more than one RHS
| begin end
Describing Lists
Syntactic lists are described using recursion
ident
| ident,
A derivation is a repeated application of rules, starting with the start symbol and ending with a sentence (all terminal symbols)
An Example Grammar
| ;
=
a | b | c | d
+ | -
| const
An example derivation
=> =>
= => a =
a = +
a = +
a = b +
a = b + const
Derivation
Every string of symbols in the derivation is a sentential form
A sentence is a sentential form that has only terminal symbols
A leftmost derivation is one in which the leftmost nonterminal in each sentential form is the one that is expanded
A derivation may be neither leftmost nor rightmost
Parse Tree
A hierarchical representation of a derivation
Ambiguity in Grammars
A grammar is ambiguous iff it generates a sentential form that has two or more distinct parse trees
An Ambiguous Expression Grammar
An Unambiguous Expression Grammar
If we use the parse tree to indicate precedence levels of the operators, we cannot have ambiguity
- |
/ const| const
Associativity of Operators
Operator associativity can also be indicated by a grammar
-> + | const (ambiguous)
-> + const | const (unambiguous)
Extended BNF
Optional parts are placed in brackets ([ ])
-> ident [()]
Alternative parts of RHSs are placed inside parentheses and separated via vertical bars
(+|-) const
Repetitions (0 or more) are placed inside braces ({ })
letter {letter|digit}
BNF and EBNF
BNF
+
| -
|
*
| /
|
EBNF
{(+ | -) }
{(* | /) }
2.4 Attribute Grammars
Context-free grammars (CFGs) cannot describe all of the syntax of programming languages
Additions to CFGs to carry some semantic info along parse trees
Primary value of attribute grammars (AGs):
Static semantics specification
Compiler design (static semantics checking)
Attribute Grammars : Definition
An attribute grammar is a context-free grammar G = (S, N, T, P) with the G.
following additions:
For each grammar symbol x there is a set A(x) of attribute values
Each rule has a set of functions that define certain attributes of the nonterminals in the rule
Each rule has a (possibly empty) set of predicates to check for attribute consistency
Let X0 X1 ... Xn be a rule
Functions of the form S(X0) = f(A(X1), ... , A(Xn)) define synthesized attributes
Functions of the form I(Xj) = f(A(X0), ... , A(Xn)), for i + |
A | B | C
actual_type: synthesized for and
expected_type: inherited for
Syntax rule: [1] + [2]
Semantic rules:
.actual_type [1].actual_type
Predicate:
[1].actual_type == [2].actual_type
.expected_type == .actual_type
Syntax rule: id
Semantic rule:
.actual_type lookup (.string)
How are attribute values computed?
If all attributes were inherited, the tree could be decorated in top-down order.
If all attributes were synthesized, the tree could be decorated in bottom-up order.
In many cases, both kinds of attributes are used, and it is some combination of top-down and bottom-up that must be used.
.expected_type inherited from parent
[1].actual_type lookup (A)
[2].actual_type lookup (B)
[1].actual_type =? [2].actual_type
.actual_type [1].actual_type
.actual_type =? .expected_type
2.5 Semantics
There is no single widely acceptable notation or formalism for describing semantics
Operational Semantics
Describe the meaning of a program by executing its statements on a machine, either simulated or actual. The change in the state of the machine (memory, registers, etc.) defines the meaning of the statement
To use operational semantics for a high-level language, a virtual machine is needed
A hardware pure interpreter would be too expensive
A software pure interpreter also has problems:
The detailed characteristics of the particular computer would make actions difficult to understand
Such a semantic definition would be machine- dependent
Operational Semantics
A better alternative: A complete computer simulation
The process:
Build a translator (translates source code to the machine code of an idealized computer)
Build a simulator for the idealized computer
valuation of operational semantics:
Good if used informally (language manuals, etc.)
Extremely complex if used formally (e.g., VDL), it was used for describing semantics of PL/I.
Axiomatic Semantics
Based on formal logic (predicate calculus)
Original purpose: formal program verification
Approach: Define axioms or inference rules for each statement type in the language (to allow transformations of expressions to other expressions)
The expressions are called assertions
Axiomatic Semantics
An assertion before a statement (a precondition) states the relationships and constraints among variables that are true at that point in execution
An assertion following a statement is a postcondition
A weakest precondition is the least restrictive precondition that will guarantee the postcondition
Pre-post form: {P} statement {Q}
An example: a = b + 1 {a > 1}
One possible precondition: {b > 10}
Weakest precondition: {b > 0}
Program proof process: The postcondition for the whole program is the desired result. Work back through the program to the first statement. If the precondition on the first statement is the same as the program spec, the program is correct.
An axiom for assignment statements (x = E):
{Qx->E} x = E {Q}
An inference rule for sequences
For a sequence S1;S2:
{P1} S1 {P2}
{P2} S2 {P3}
An inference rule for logical pretest loops
For the loop construct:
{P} while B do S end {Q}
Characteristics of the loop invariant
I must meet the following conditions:
P => I (the loop invariant must be true initially)
{I} B {I} (evaluation of the Boolean must not change the validity of I)
{I and B} S {I} (I is not changed by executing the body of the loop)
(I and (not B)) => Q (if I is true and B is false, Q is implied)
The loop terminates (this can be difficult to prove)
The loop invariant I is a weakened version of the loop postcondition, and it is also a precondition.
I must be weak enough to be satisfied prior to the beginning of the loop, but when combined with the loop exit condition, it must be strong enough to force the truth of the postcondition
Evaluation of axiomatic semantics:
Developing axioms or inference rules for all of the statements in a language is difficult It is a good tool for correctness proofs, and an excellent framework for reasoning about programs, but it is not as useful for language users and compiler writers
Its usefulness in describing the meaning of a programming language is limited for language users or compiler writers
Denotational Semantics
Based on recursive function theory
The most abstract semantics description method
Originally developed by Scott and Strachey (1970)
The process of building a denotational spec for a language (not necessarily easy):
Define a mathematical object for each language entity
Define a function that maps instances of the language entities onto instances of the corresponding mathematical objects
The meaning of language constructs are defined by only the values of the program's variables
The difference between denotational and operational semantics: In operational semantics, the state changes are defined by coded algorithms; in denotational semantics, they are defined by rigorous mathematical functions
The state of a program is the values of all its current variables
s = {, , , }
Let VARMAP be a function that, when given a variable name and a state, returns the current value of the variable
VARMAP(ij, s) = vj
Decimal Numbers
The following denotational semantics description maps decimal numbers as strings of symbols into numeric values
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
| (0 | 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9)
Mdec('0') = 0, Mdec ('1') = 1, , Mdec ('9') = 9
Mdec ( '0') = 10 * Mdec ()
Mdec ( '1) = 10 * Mdec () + 1
Mdec ( '9') = 10 * Mdec () + 9
Expressions
Map expressions onto Z {error}
We assume expressions are decimal numbers, variables, or binary expressions having one arithmetic operator and two operands, each of which can be an expression
Me(, s) =
case of
=> Mdec(, s)
=>
if VARMAP(, s) == undef
then error
else VARMAP(, s)
=>
if (Me(., s) == undef
OR Me(., s) =
undef)
then error
else
if (. == + then
Me(., s) +
Me(., s)
else Me(., s) *
Me(., s)
...
Assignment Statements
Maps state sets to state sets
Ma(x := E, s) =
if Me(E, s) == error
then error
else s = {,,...,},
where for j = 1, 2, ..., n,
vj = VARMAP(ij, s) if ij x
= Me(E, s) if ij == x
Logical Pretest Loops
o Maps state sets to state sets
Ml(while B do L, s) =
if Mb(B, s) == undef
then error
else if Mb(B, s) == false
then s
else if Msl(L, s) == error
then error
else Ml(while B do L, Msl(L, s))
The meaning of the loop is the value of the program variables after the statements in th