III B.Tech I Semester

Academic Dairy

For 2013-2014

Principles of Programming Languages

Faculty: Mr. A. Malli Karjuna Reddy

Mr. G. Balram

UNIT I

Syllabus:

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 Implementation–Compilation and Virtual Machines, programming environments.

Objectives:

  • understand the basic concepts of programming languages
  • understand how to Evaluate a Language
  • understand the various implementation methods
  • know the Use of Various Languages

Lecture plan:

S.No / Topic / Date / No. of lectures
1 / Reasons for studying, concepts of programming languages / 1
2 / Programming domains / 1
3 / Language Evaluation Criteria / 1
4 / Influences on Language design, Language categories / 1
5 / Programming Paradigms – Imperative, Object Oriented, functional Programming , Logic Programming / 1
6 / Programming Language Implementation / 1
7 / programming environments / 1
7

Important Questions:

1.Explain in detail various phases in the process of compilation?

2. Give an example of how aliasing deters reliability? [Apr 2009]

3. Why it is useful for a programmer to have some background in language design? [Dec 2010]

4. How can knowledge of programming language characteristics benefit the whole computing community? [Dec 2010]

5. Difference between compilation and interpretation? [Apr/May 2011]

6.What role does the symbol table play in a complier? [Nov/Dec 2008]

Assignment Questions:

1. What is a linker? Explain the responsibilities of the linker?

2. Explain the different aspects of cost of a programming language?

3. What common programming language statements in your opinion is most deter to readability?

Case Study

1. Was the first high level programming language you learned, implemented within pure interpreter, a hybrid implementation system or a compiler? If yes, justify?

2. Enumerateevaluation criteria of some programming language, you know using the criteria described in the chapter?

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.

UNIT II

Syllabus:

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, denotational semantics and axiomatic semantics for common programming language features.

Objectives:

  • understand the concepts of Syntax and Semantics of various languages
  • know various formal methods of describing syntax

Lecture plan:

S.No / Topic / Date / No. of lectures
1 / General Problem of describing Syntax and Semantics / 1
2 / Formal methods of describing syntax – BNF, EBNF for common programming languages features / 2
3 / Parse trees / 1
4 / Ambiguous grammars / 1
5 / Attribute grammars / 1
6 / Denotational semantics / 1
7 / axiomatic semantics for common programming language features / 1
8

Important Questions:

1. In what fundamental way do operational semantics and denotational semantics differ?

2. What are weakest preconditions in axiomatic semantics?

3. Develop an unambiguous grammar that describes the if statement? [Apr/May 2011].

4. Describe the basic concept of denotational semantics? [Apr/May 2011]

5. What is the difference between synthesized and inherited attributes? [Apr/May 2010]

6. Discuss the following? [Dec 2010]

1) Assignment statements

2) Logical pretest loops

7. What is a Language generator? Explain how the language generator used to generate the sentences of a language? [Dec 2010]

8. In what fundamental way do the operational and denotional semantics differ?

Assignments:

1. Define CFG. State whether CFG is a language generator or recognizer?

2. Explain with an example how operator associativity can be incorporated in grammars?

Case Study

assign <id> = expr

id> A|B|C

<expr> <expr> + <term

|term

term> <term*factor

|factor

factor> (<expr>)

|id

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 III

Syllabus:

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.

Objectives:

  • understand the various Data types
  • understand the basic concepts of binding
  • understand the uses of various data types
  • understandthe various languages variable initialization

Lecture plan

S.No / Topic / Date / No. of lectures
1 / Data types: Introduction, primitive, character / 1
2 / User defined, array, associative, record / 1
3 / Union, pointer and reference types / 1
4 / Design and implementation uses related to these types / 1
5 / Names, Variable, concept of binding / 1
6 / Type checking, strong typing, Type compatibility / 1
7 / Named constants, variable initialization / 1
7

Important Questions:

1. What are the advantages of user-defined data types?

2. Discuss in detail the primary design issues for names?

3.Explain pointers, reference types, design issues of pointers, operations on pointers, pointer problems and implementation of pointer and reference types?

4. Describe how the pointers used in C and C++ with examples? [Dec 2010]

5. Describe the various problems associated with pointers?

6. Define the following? [Dec 2010]

a) Stack Dynamic

b) Explicit Heap Dynamic

c) Implicit Heap Dynamic

d) Static

7. Difference between Static and Dynamic strings?

Assignment:

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?

2. Describe the process of Array initialization?

3.Explain all of the difference between subtypes and derived types?

4. Define union, free union and discriminated union?

Case Studies

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 xis printed in procedure sub1?

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?

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?

UNIT-IV

Syllabus:

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

Objectives:

  • understand the Expressions and Statements
  • understand the concepts of Compound Statements, Selection, Iteration
  • understand the uses of Short circuit evaluation mixed mode assignment
  • understand the various languages Control Structures

Lecture plan

S.No / Topic / Date / No. of lectures
1 / Arithmetic relational and Boolean expressions , Short circuit evaluation mixed mode assignment / 2
2 / Assignment Statements, Control Structures – Statement Level / 2
3 / Compound Statements, Selection / 1
4 / Iteration, Unconditional Statements / 1
6

Important Questions:

1. Explain in detail multiple selection constructs? [Apr/May 2009]

2. How does operand evaluation order interact with functional side effects? [Apr/May 2011]

3. What are design issues for character string types? [Apr/May 2011]

4. Describe narrowing and widening conversion? [Dec 2010]

5. Explain about the iteration based Data structures? [Dec 2010]

6. Discuss the benefits of operator overloading?

7. Explain about the coercion in expressions? [Dec 2010]

Assignment:

1. What are the advantages and disadvantages of allowing mixed-mode arithmetic expressions?

2. Explain the problems associated with Unconditional Branching?

3. List out Errors that can occur in Expression Evaluation?

Case Studies

1)Let the function fun is defined as

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-V

Syllabus:

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.

Objectives:

  • Understand the use of subprograms
  • Understand the different parameter passing methods
  • To know the concepts of Scope and lifetime of variable

Lecture plan

S.No / Topic / Date / No. of lectures
1 / Fundamentals of sub-programs / 1
2 / Scope and lifetime of variable, static and dynamic scope / 1
3 / Design issues of subprograms and operations / 1
4 / Local referencing environments, Parameter passing methods / 1
5 / Overloaded sub-programs, generic sub-programs / 1
6 / Parameters that are sub-program names, Design issues for functions / 2
7

Important Questions:

  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? [Apr/May 2011]
  2. Define Shallow and deep binding for referencing environment of subprograms that have been passed as parameter? [Apr/May 2011]
  3. Write about Co routines?
  4. Explain the considerations for choosing parameter passing methods?
  5. What are the Generic characteristics of subprogram?
  6. Explain, how multi dimensional arrays can passed as arguments in Ada language?

Assignment:

  1. Explain the Various Design issues that are involved in functions?
  2. Difference between procedures and functions?

Case Study

Consider the following program

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

UNIT-VI

Syllabus:

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
Concurrency: Subprogram level concurrency, semaphores, monitors, massage passing, Java threads, C# threads.

Objectives:

  • know about various Abstract Data types
  • know uses of abstraction &ADT
  • know about Concurrency
  • understand Various levels of concurrency
  • understand the concepts of , semaphores, monitors, massage passing, Java threads, C# threads

Lecture plan

S.No / Topic / Date / No. of lectures
1 / Abstractions and encapsulation / 1
2 / Language examples, C++ parameterized ADT, Object oriented programming in small talk, C++ / 2
3 / Java, C#, Ada 95, Subprogram level concurrency, semaphores, Monitors / 3
4 / Massage passing, Java threads, C# threads / 2
8

Important Questions

1.Explain the difference Physical and logical concurrency?

2. What are three possible levels of concurrency in programs? Explain?

3. What is the use of Friend function in C++, Explain with example?

4. Write short notes on C# threads?

5. What are different states a task can be? Explain?

6. Explain In detail Cooperation synchronization?

Assignment:

1. What is the primary problem with using semaphores to provide synchronization?

2. In what different places can the definition of a C++ member function appears?

3. What is a C++ Name space? What is it purpose?

Case Studies

1)What dangers are avoided in Java and C# by having implicit garbage collector, relative to C++?

2)What is the best action a system can take when deadlock is detected?

UNIT-VII

Syllabus:

Exception handling: Exceptions, exception Propagation, Exception handler in Ada, C++ and Java.
Logic Programming Language: Introduction and overview of logic programming, basic elements of prolog, application of logic programming.

Objectives:

  • know about Exception handling in various languages
  • understand concepts of Logic Programming Language
  • know application of logic programming

Lecture plan:

S.No / Topic / Date / No. of lectures
1 / Exceptions, exception Propagation / 2
2 / Exception handler in Ada / 1
3 / Exception handler in C++ and Java / 1
4 / Introduction and overview of logic programming / 2
5 / Basic elements of prolog, Application of logic programming / 2
8

Important Questions:

1.Explain detailed compassion of Exception handling capablites of C++ and those of Java?

2. Explain the following with examples?

a) Exception handler

b) Disabling an Exception

c) Continuation

3. How are Exceptions bound to handlers in C++?

Assignment:

  1. Explain in detail about Exception handling in Ada?

Case Study

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?

UNIT-VIII

Syllabus:

Functional Programming Languages: Introduction, fundamentals of FPL, LISP, ML, Haskell, application of Functional Programming Languages and comparison of functional and imperative Languages

Objectives:

  • know about various Functional Programming Languages
  • understand the application of Functional Programming Languages
  • know comparison of functional and imperative Languages

Lecture Plan:

S.No / Topic / Date / No. of lectures
1 / Fundamentals of FPL, LISP, ML / 2
2 / Haskell, Application of Functional Programming Languages / 2
3 / Comparison of functional and imperative Languages
Scripting languages / 4
8

Important Questions:

1) Explain

a)Common Lisp

b)Haskell

c)ML

2) Discuss the applications of functional languages?

3) Explain the difference between Imperative and functional languages?

4) Describe the semantics of COND and LET?

Assignment:

1.Explain the difference between CONS, LIST and APPENED?

2.Write a Lisp function Fib(n) that computes a nth Fibonacci number?

Case Studies

Write the quick sort algorithm in scheme language

Write the scheme function that removes the last element from a give list