Principles of Programming Languages עקרונות שפות תכנות Prof. Mira Balaban

 Course number : 202.1.2051  Mandatory  Credits : 5  Course Site: http://www.cs.bgu.ac.il/~ppl162  Prerequisites: o Data Structures – 202.1.1031 o Automata and Formal Languages – 202.1.2011

Course Objectives

This course concerns the interplay between problem modeling and programming languages. relies on having good models that are written in a language that can support the modeling concepts. There are four main objectives:

 Learning principles of programming languages: The elements of programming languages; abstraction means in programming languages; formal definition of programming languages – concrete syntax, abstract syntax, operational semantics; program correctness – type checking and type inference systems.  Learning the essence of program execution by evaluators: Interpreters, compilers.  Understanding programming paradigms: How the above topics are realized in , programming and .  Learning principles of program design: Abstraction, contracts, modular architecture, testing.

The course is a mixture of theory and practice. All theoretical topics involve implemented software, and all course assignments involve a major amount of programming. The course combines two main approaches in teaching principles of programming languages: Using a single language for demonstrating all language aspects vs. introduction of multiple languages as representatives of different aspects. The course uses the Scheme language for teaching the general theory and practice of language design and implementation. The language is used for introducing the Logic .

Course Requirements

 4-hours weekly lectures  2-hours weekly exercise sessions  6 theoretical and programming assignments. Can be individual or in pairs  Midterm  Final exam Grade Policy:

. Pass condition for the course: Passing the final exam and submitting all assignments. . The final grade is computed according to the following formula. . Midterm weight: If (Midterm grade > Exam grade) then Midterm weight := 20% else Midterm weight := 10%

5 ∑푖=1 ℎ푤푖+0.9ℎ푤6 . Assignment grade := 5 . Assignment weight := 5 ∑ ℎ푤푖 If 푖=1 < Exam grade + 35 5 then Assignment weight := 20% else Assignment weight := 10%

. Exam weight := 1 – Assignment weight – Midterm weight. . Final grade := (Assignment weight * Assignment grade) + (Midterm weight * Midterm grade) + (Exam weight * Exam grade)

Detailed Syllabus

1. The Elements of Programming a. The elements of programming b. Procedure design using contracts c. Hierarchical data types: Pairs and lists d. Procedures and the processes they generate e. Higher-order procedures f. Polymorphic procedures 2. Syntax, semantics, types a. Syntax: Concrete and abstract b. Operational semantics: The substitution model c. Types 3. Higher-Order Procedures Revisited a. Local procedures b. The sequence interface c. Partial evaluation using function Currying d. Revisiting: Primitive procedures, User-defined procedures, derived expressions, Special operators 4. Abstraction on Data and on Control (Behavior) a. Data abstraction: Abstract data types b. Lazy lists c. Continuation passing style programming 5. Type Correctness a. What is type checking/inference b. Static type inference for Scheme c. Type checking and inference using type constraints approach 6. Evaluators for Functional Programming a. Abstract syntax parser b. A meta-circular evaluator for the substitution model c. The environment model evaluation d. Meta-circular evaluator for the environment-based operational semantics e. A meta-circular compiler for functional programming 7. Logic Programming – in a Nutshell a. Relational logic programming b. Logic programming c. Meta-tools: Backtracking optimization (cuts); Unify; Meta- circular interpreters d. Prolog 8. Imperative Programming using Scheme a. State-based modeling b. Operational semantics: Extending the environment model with local state management c. Extending the environment model and compiler d. Type-checking/inference with assignments e. Costs of introducing mutation 9. Conclusion: Techniques, Principles and Language comparison

References

Lecture notes in http://www.cs.bgu.ac.il/~ppl162/wiki.files/Lectures/lecture-notes-chapters-1-8.pdf

Additional reference books:

1. Structure and Interpretation of Computer Programs, by H. Abelson and G.J. Sussman, MIT Press, 2nd edition, 1996. 2. How to Design Programs, by M. Felleisen, R.B. Findler, M. Flatt and S. Krishnamurthi, MIT Press, 2003. 3. Programming Languages: Application and Interpretation, by S. Krishnamurthi, Version 26.4.2007. 4. The Art of Prolog, 2nd edition, by L. Sterling and E. Shapiro, MIT Press, 1994. 5. Essentials, by H.E. Bal and D. Grune, Addison-wesley, 1994. 6. Essentials of Programming Languages, 3nd edition, by D.P. Friedman and M. Wand, MIT Press, 2008.