CS 381: Programming Language Fundamentals (Fall 2008)


Course Description

CS 381, Programming Languages, is a four-credit course for undergraduate students. This course gives an introduction to the concepts found in a variety of programming languages and to languages from a number of different paradigms. Topics to be covered are: Haskell, Prolog, scoping, parameter passing, types, polymorphism, exception handling, semantics.

Contents of this web page:

Prerequisites

Some parts of the class require knowledge about the following concepts: Data structures and discrete math should have been covered in your previous classes, but maybe you have never seen a formal definition of a grammar. I will explain grammars in class, but I encourage you to read about grammars in advance. Could do this on the above referenced web site and/or in the textbook, Chapter 4.1.2.

Back to the table of contents

Background Reading

This class is not based on one particular textbook. However, I recommend as backup reading material the following book.
Concepts in Programming Languages
By John C. Mitchell, published by Cambridge University Press 2003.

This textbook is, however, not required. All relevant material will be presented on my slides that will be accessible here.

Back to the table of contents

Haskell

Most programming will be done in Haskell, a modern functional programming language. In particular, we will use Haskell as a formal notation to explain concepts of programming languages. It is therefore absolutely essential that you acquire profound programming skills in Haskell! I will introduce Haskell alongside with programming language concepts during the first seven weeks of the class. To become confident in writing Haskell programs, you should work on all the (non-graded) small programming assignments that I will give during class. A lot of information on Haskell (documentation, textbooks, compilers, examples, ...) can be found on the website
haskell.org
There you will also find links to several tutorials. You might start by looking at the short summary. The definitive reference for all questions regarding Haskell is the
Haskell Report
It includes a complete language definition.

We will mainly use the GHC compiler/interpreter, which is available on many different platforms. It is already installed on the CS and ENGR machines, but in general only on Unix. It is also installed on the Windows machines in the Dearborn 119 lab.

To start the GHC interpreter, just enter ghci in the Unix shell. In GHCi, enter :? for help on commands; enter :q to quit the interpreter. An alternative Haskell implementation that supports a carefully selected subset of Haskell is the Helium compiler/interpreter, which has been specifically designed to support the beginning Haskell programmer in learning Haskell. Here is a file that you might want to use (and customize) for testing your programs.

TestScript.hs
And here is a file that we usein the Haskell "WorkOut" example.
Test.hs

Information about Prolog is also available on the Internet, see the links provided here. We will be using SWI-Prolog.

Back to the table of contents

Class Schedule

The following table shows the topics that are covered in each class and the due dates for homework.

Week Date  TopicsDue
1 Sep 30 Introduction to Haskell, GHC
Oct 02 Languages, Syntax
2 Oct 07 Abstract Syntax, [Haskell] Data Types
Oct 09 Expression Languages and Semantics, [Haskell] Function Definitions and Recursion
3 Oct 14 Haskell Practice
Oct 16 Languages and Semantics, (HW 1 Solutions) HW 1
4 Oct 21 Types, Safety, Dynamic and Static Type Checking, [Haskell] Pattern Matching
Oct 23 Polymorphism, Type Inference, [Haskell] Parametric Polymorhpism
5 Oct 28 Functions, Local Scope, Runtime Stack, (HW 2 Solutions) HW 2
Oct 30 Dynamic vs. Static Binding, Recursion, [Haskell] Anonymous & Higher-Order Functions
6 Nov 04 Parameter Passing, Review for Midterm Exam, (HW 3 Solutions) HW 3
Nov 06 MIDTERM EXAM 2
7 Nov 11 Midterm Solutions, Exceptions, Programming Paradigms
Nov 13 Programming Paradigms, (HW 4 Solutions) HW 4
8 Nov 18 [Prolog] Predicates, Goals, and Rules
Nov 20 [Prolog] Recursion and Backtracking
9 Nov 25 [Prolog] Terms and Lists, Arithmetic
Nov 27 NO CLASS: Thanksgiving
10 Dec 02 [Prolog] More Examples (HW 5 Solutions) HW 5
Dec 04 Review for Final Exam
11 Dec 12 FINAL EXAM (9:30am - 11:20am) 2

Back to the table of contents

Slides and Programs

I will try to make the slides available online before each lecture, but be aware that there might be some last-minute changes.

Topic Slides Update Programs
0. Introduction [pdf] 10/02/08
1. Languages [pdf] 10/02/08
2. Syntax [pdf] 10/06/08 SentSyn.hs SentPP.hs BoolSyn.hs BoolPP.hs Stmt.hs
3. Semantics [pdf] 10/08/08 BoolSyn.hs BoolSem.hs ExprSyn.hs ExprSem.hs Shape.hs ShapePP.hs Move.hs Move2.hs ExprErr.hs Expr2.hs RegMachine.hs RegMachine2.hs
4. Types [pdf] 10/21/08 Expr2.hs Expr2Unsafe.hs TypeCheck.hs TypedGeoLang.hs
5. Scope [pdf] 10/28/08 FunD.hs Fun.hs FunRec.hs Trace.hs
6. Parameter Passing [pdf] 11/10/08 cbv.c cbr.c cbrP.c cbvr.c
7. Exceptions [pdf] 11/10/08
8. Programming Paradigms [pdf] 11/13/08 Imp.hs Fun.hs Obj.hs STrace.hs
9. Prolog [pdf] 11/20/08 friends.pl mouse.pl family.pl member.pl negation.pl

Back to the table of contents

Homework

  1. Abstract Syntax [pdf] (Version 10/06/08) Due date: 10/16/08 (noon, before class!!!)
    Examples illustrating function definitions to generate syntax trees: GenExpr.hs (which imports ExprSyn.hs) and GenBin.hs
    Sample solutions: Syntax.lhs
  2. Semantics [pdf] (Version 10/16/08) Due date: 10/28/08 (noon, before class!!!)
    Definitions to render Mini Logo results: svg.hs
    Sample solutions: Semantics.lhs
    Mini Logo with svg visualization: MiniLogoSyn.hs MiniLogoSem.hs
  3. Types [pdf] (Version 10/28/08) Due date: 11/04/08 (noon, before class!!!)
    Sample solutions: Types.lhs
  4. Runtime Stack, Scoping, and Parameter Passing [pdf] (Version 11/03/08) Due date: 11/13/08 (noon, before class!!!)
    Sample solutions: Blocks.sol
  5. Prolog [pdf] (Version 11/19/08) Due date: 12/02/08 (noon, before class!!!)
    Template with data for exercise 1: hw5.pl
    Sample solutions: hw5-sol.pl
    Test cases: prolog.test

Back to the table of contents

Grading (Homework)

Grading (General)

Grades will be roughly computed as follows: For 90% or more, you get an A; for less than 30% you get an F. The remaining grades in between are assigned linearly. I might lift individual grades if clustering of points achieved by students suggests so (but I won't assign grades worse than indicated by the above linear schema). If you are too lazy to calculate, you can look up grades in this table.

Grading Results

I will hand out corrected homework and exams in class. If you should miss that lecture, you can get your homework during my office hour. In the table given below, find in the leftmost column the row that matches your personal keyword. That row gives your current point score.
Note: I have computed the homework average by taking only your four best homework results into account.

Course results (HW 1-5, Midterm)
Median AverageHomework 1 C- C
Homework 2 A- B
Homework 3 A B+
Midterm B- B-
Homework 4 A- B+
Homework 5 B+ B+

Back to the table of contents

Important Dates and Times

Class Time: TR noon - 1:20pm Nash 206
Office hours: Monday noon - 1pm KEC 3047
Tuesday 9am - 10am KEC 3047
Wednesday3pm - 4pm KEC 3047
Midterm Exam: Thursday, Nov 06noon - 1:00pm Nash 206
Final Exam: Friday, Dec 129:30am - 11:20am Nash 206

Back to the table of contents


last change: December 04, 2008 Martin Erwig  erwig@eecs.oregonstate.edu