CS 381: Programming Language Fundamentals (Spring 2016)


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 over 100 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.

Piazza

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

Prerequisites

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

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 basic Haskell concepts in the first two weks 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.
haskell.org

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.

TestScript.hs
I have also put an introductory Haskell textbook on reserve in the Valley library:

Haskell: The Craft of Functional Programming
By Simon Thompson. Addison-Wesley, 3rd ed., 2011.

Back to the table of contents

Haskell Exercises

Here are two sets of exercises that help you learn how to define data types and functions on data types and with the programming with lists.

Back to the table of contents

Prolog

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

Except for the very first lecture, 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/29/16
1. Haskell [pdf] 03/31/16 [Solutions] WhyParadigms.pdf Examples.hs
2. Syntax [pdf] 04/12/16 SentSyn.hs SentPP.hs BoolSyn.hs BoolPP.hs Stmt.hs Bin.hs Reg.hs ExprSyn.hs
3. Semantics [pdf] 04/20/16 swap.c BoolSem.hs ExprSem.hs Shape.hs ShapePP.hs Move.hs Move2.hs ExprErr.hs Expr2.hs RegMachine.hs RegMachine2.hs
4. Types [pdf] 04/24/16 Expr2.hs Expr2Unsafe.hs TypeCheck.hs ExprPair.hs ExprNPair.hs
5. Scope [pdf] 05/09/16 Var.hs FunDynScope.hs FunStatScope.hs FunRec.hs Trace.hs
6. Parameter Passing [pdf] 05/11/16 cbv.c cbr.c cbrP.c cbvr.c
7. Exceptions [pdf] 05/16/16
8. Programming Paradigms [pdf] 05/16/16 Imp.hs FunStatScope.hs FunRec.hs Obj.hs STrace.hs
9. Prolog [pdf] 05/26/16 [Family Tree Solutions] socrates.pl likes.pl friends.pl mouse.pl family.pl

Back to the table of contents

Homework

Note: Late submissions will not be accepted!
  1. Abstract Syntax [pdf] (Version 04/07/16) Due date: 04/21/16 (2pm)
    An example illustrating a function definition to generate syntax trees: GenExpr.hs (which imports ExprSyn.hs)
    Sample solutions: Syntax.lhs
  2. Semantics [pdf] (Version 04/21/16) Due date: 05/03/16 (2pm)
    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 04/30/16) Due date: 05/12/16 (2pm)
    Sample solutions: Types.lhs
  4. Runtime Stack, Scoping, and Parameter Passing [pdf] (Version 05/11/16) Due date: 05/24/16 (2pm)
    Sample solutions: Blocks.sol
  5. Prolog [pdf] (Version 05/24/16) Due date: 05/31/16 (2pm)
    Template with data for exercise 1: hw5.pl
    Sample solutions: hw5sol.pl
    Test cases: prolog.test

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 and exams in class. If you should miss that lecture, you can get your homework 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 117%37%C/C
Quiz 214%64%B/B
Quiz 314%33%C/C
Quiz 46%49%B-/B-
Quiz 517%32%C+/C+
Quiz 642%59%B+/B
Quiz 747%86%A-/A-
HW 176%93%A/A
HW 282%93%A/A
HW 390%98%A/A
HW 477%99%A/A
HW 547%86%A/A-
Midterm12%44%B-/B-
Final11%52%B/B
Course7%52%B/B

As promised, as a reward for their active contributions on Piazza, one student's grade was lifted from an A- to an A. Another student who would have benefited already got an A.

Back to the table of contents


last change: June 16, 2016 Martin Erwig  erwig@oregonstate.edu