CS 381: Programming Language Fundamentals (Spring 2018)

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:

Classroom Policies

We have about 170 students in this class. To support a more focused learning experience for everyone in such a big class, I ask you to adhere to the following rules during lectures.


In this class we will be using the Piazza platform for: You should sign up for Piazza and join the class page ASAP so that you don't miss any important announcements!

CS 381 on Piazza

The Piazza Q&A platform is geared toward students helping other students. Anybody can post or answer a question, and you can even do so anonymously if you're shy. The instructor can then revise (if needed) and endorse student answers so you can be confident in the quality of the response. Students are strongly encouraged to post questions (about lectures, quizzes, or anything class-related) to Piazza first, rather than email the instructor. Students should also frequently check in to answer other students' questions. Not only will this enable everyone to get help quickly, but teaching someone else is the best way to learn something, so you'll be improving your understanding of the material as well.

I will reward active participation on Piazza by giving extra credit to those students who contributed to the discussion through good questions and answers!

The concept of peer instruction is based on the idea that students discuss class material with each other during class after having answered a particular question differently. These individual discussions help clarify specific misunderstandings and contribute to a solid understanding of the class material.

Back to the table of contents


This class assumes background 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. You could do this on the above referenced web site or in the book recommended for background reading, Chapter 4.1.2.

Back to the table of contents

Background Reading

This class does not use a specific textbook. However, I recommend as backup reading material the following book.
Concepts in Programming Languages
By John C. Mitchell, 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


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 basic Haskell concepts in the first two weeks of class and then additional features alongside with programming language concepts during the next five 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 following website.

Here are some tutorials:

The definitive reference for all questions regarding Haskell is the Haskell Report, which includes a complete language definition. We will use the GHC interpreter, which is available on many different platforms. It is already installed on the CS and ENGR machines, but in general only on Unix. 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.

Here is a file that you might want to use (and customize) for testing your programs.


Back to the table of contents

Haskell Exercises

Here are several exercises that help you learn how to define data types and functions on data types and with the programming with lists. You can also find exercises in the Code Supplement to my book.

Back to the table of contents


Information about Prolog can be found in the the book recommended for background reading, Chapter 15 and is also available on the Internet.

Here are some resources for learning to program in Prolog:

We will be using SWI-Prolog. You should install this on your machine.

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 Code and other supporting material
0. Introduction [pdf] 03/31/18
1. Haskell [pdf] 03/31/18 [Solutions] Practice.hs
2. Syntax [pdf] 04/17/18 SentSyn.hs SentPP.hs BoolSyn.hs BoolPP.hs Stmt.hs Bin.hs Reg.hs ExprSyn.hs
3. Semantics [pdf] 04/20/18

Back to the table of contents


Note: Late submissions will not be accepted!
  1. Abstract Syntax [pdf] (Version 04/17/18) Due date: 04/26/18 (2pm)
    An example illustrating a function definition to generate syntax trees: GenExpr.hs (which imports ExprSyn.hs)

Back to the table of contents

Grading (Homework)

Grading (General)

Grades will be 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, quizzes, and exams in class. Should you miss that lecture, you can pick up your homework/quiz/exam during my office hour. Due to the large number of students in the class I plan to have you pick up your quizzes and exams yourself from a pile of exams at the beginning/end of lectures. I do respect your privacy, and if you prefer to have your quiz/exam handed back to you personally, please send me an email. In that case I will not return your exam in class and keep it in my office for you to pick up in person.

Quiz/ExamGrade Distribution
    A       B or better     Median/Average  
Quiz 112%35%C/C

Back to the table of contents

last change: April 20, 2018 Martin Erwig  erwig@oregonstate.edu