Spring 2017

CS 291: Programming Language Paradigms

Instructor

Tony Mullen
410 Thompson Hall

Phone: 253.879.3562
Email: tmullen@pugetsound.edu

Office hours

My office hours for Fall 2016 are:

Mon, Tues, Wed, & Fri: 11:00-11:50

You can make an appointment to meet at other times also.

I try to respond to emails within 24 hours. You should not expect a response to emails received after 5:00 PM until the next day.

Attendance and lateness policy

Students are expected to attend class and labs. Multiple absences without a written excuse can result in a reduced grade for the class.

If you are not present when attendance is taken, but arrive to class later in the period, be sure to make sure I know that you were in attendance.

Academic integrity

Please ensure that any work you take credit for is your own. Homework should be assumed to be individual work unless it is explicitly given as group work.

When working on individual coding assignments (i.e. all assignments not explicitly labeled as pair or group assignments) you should never look at other people's code for your benefit or allow them to look at yours for their benefit. You may look at another person's code in order to help them identify a problem they are having.

There are sophisticated tools available to identify code plagiarism. Simply changing superficial characteristics of code (variable names, line breaks, spacing) is not enough to conceal when a program has been cribbed. Aside from this, however, someone who copies code cheats themselves out of the opportunity to learn the material. Sooner or later, this will catch up to them.

If your work involves contributing to code written by other people (as is often the case when working with open source software) always be aware of and respectful of the license governing the use of the code, and always be clear about where your own contributions begin and end.

Please review the Academic Integrity section of the UPS Student Handbook for more specifics on what sorts of behavior constitute violations of academic integrity.

Devices in class

Please avoid using devices during class in ways that distract yourself or others.

General policies

The university is a place for respectful exchange of information and ideas.

University-wide policies regarding student conduct and integrity can be found in the UPS Student Handbook.

If you have any questions or problems related to this class or anything else I may be able to help with, please don't hesitate to email me or drop by my office any time to talk.

Special Accommodations

Academic accommodations are available for students with disabilities who are registered with the Office of the Office of Accessibility and Accommodations. If you have a physical, psychological, medical or learning disability that may impact your course work, please contact Peggy Perno, Director of the Office of Accessibility and Accommodations, 105 Howarth, 253.879.3395. She will determine with you what accommodations are necessary and appropriate. All information and documentation is confidential.

I also encourage all students having difficulty, whatever the reason, to consult privately with me at any time.

Emergency Procedures

Please review university emergency preparedness and response procedures posted at www.pugetsound.edu/emergency/. There is a link on the university home page. Familiarize yourself with hall exit doors and the designated gathering area for your class and laboratory buildings.

If building evacuation becomes necessary (e.g. earthquake), meet your instructor at the designated gathering area so she/he can account for your presence. Then wait for further instructions. Do not return to the building or classroom until advised by a university emergency response representative. If confronted by an act of violence, be prepared to make quick decisions to protect your safety. Flee the area by running away from the source of danger if you can safely do so. If this is not possible, shelter in place by securing classroom or lab doors and windows, closing blinds, and turning off room lights. Lie on the floor out of sight and away from windows and doors. Place cell phones or pagers on vibrate so that you can receive messages quietly. Wait for further instructions.

Course description

In this class students will study the differences between programming language paradigms and become acquainted with styles of programming other than the most widely used procedural and object-oriented styles.

Lectures and readings will provide an overview of some of the most important programming paradigms, including logic programming, dataflow programming, and functional programming.

Much of the course will be dedicated to acquiring practical working competency in two specific languages representing key programming paradigms, namely Prolog for logic programming, and Haskell for functional programming.

Goals of the class

By the end of this class students will

  • Understand the differences and similarities between between the functional, logic, and imperative paradigms
  • Be familiar with first-order predicate calculus and lambda calculus and understand how they relate to computer programming
  • Be able to write logic programs in Prolog
  • Be able to write functional programs in Haskell
  • Gain an appreciation for the benefits of declarative programming
  • Understand the concept of "purity" as it applies to programming language paradigms

Lecture slides

Lecture slides for this class will be posted soon after the lecture is completed. You can find them here.

Textbook & required materials

The main textbooks/tutorials we'll be using in this class are all available freely online. Several of them can be purchased as hard copies also.

Learn Prolog Now, by Patrick Blackburn, Johan Bos, and Kristina Striegnitz

Learn You a Haskell for Great Good!, by Miran Lipovača

Real World Haskell, by Bryan O'Sullivan, Don Stewart, and John Goerzen

Calendar

Week Date Topic Reading Assignment
1 1/18 Programming language paradigms, logic, Prolog intro Predicate logic, LPN Ch 1 Homework 1
Due Wed 1/25
2 1/23 Facts, Rules, and Queries LPN Ch 2, 3 Homework 2
Due Mon 1/30
3 1/30 Arithmetic, recursion, lists LPN Ch 4, 5 Homework 3
Due Wed 2/8
4 2/6 More on lists, trees LPN Ch 6, 9 Homework 4
Due Wed 2/15
5 2/13 Search Trees, LPN Ch 10, 11 Homework 5
Due Wed 2/22
Pair project
Due Fri 3/24
6 2/20 Cuts and Negation Homework 6
Due Wed 3/1
7 2/27 Difference lists; Collecting solutions Homework 7
Due Wed 3/8
8 3/6 Review Midterm Exam Fri 3/10
9 3/13 Spring
break
10 3/20 Intro to Haskell, Expressions and functions
No class Fri, 3/24
Why learn functional programming?
LYAH Section 1, 2, 3
Homework 8
Due Fri 3/31
11 3/27 Types and type classes, List comprehensions LYAH Section 4,5 Homework 9
Due Fri 4/7
12 4/3 Lambda abstraction, Recursion LYAH Section 6, 7 Homework 10
Due Fri 4/14
13 4/10 Functions as values LYAH Section 8, 9 Homework 11
Due Fri 4/21
14 4/17 Higher order functions LYAH Section 10 Homework 12
Due Fri 4/28
Bert Bos Puzzle,
Haskell version

Due Wed 5/10
15 4/24 IO and Monads LYAH Section 11 Homework 13
Due Fri 5/5
16 5/1 Modules, review LYAH Section 12
Finals Final Exam Fri 5/12 12:00PM-2:00PMy

Grading

This class is graded on the following criteria:

  • 10% Attendance & class participation
  • 40% Weekly homework
  • 30% Midterm (pair) & final programming assignments (15% each)
  • 20% Midterm & final exams (10% each)

Homework and lateness Homework assignments are individual assignments unless explicitly described otherwise. Late homework assignments will be penalized by 20% per day late, with no credit possible after 4 days late. Any extension requests for any reason should be made through the Student Accessibility and Accommodations office.

There will be two larger-scale programming assignments (projects) which you will have more time to work on. The first of these will be given around the middle of the semester and may (optionally) be done in pairs. In it, you will solve a moderately challenging problem using Prolog. The second, given around the end of the semester, will be to solve the same problem using Haskell. The second project will be done individually. The same lateness policy applies for these projects as for the regular homework assignments.

Coding homework grade rubric

Grades on coding assignments are at the discretion of the grader (or myself, depending on the arrangement for the term). The general guidelines for how you should expect your code to be assessed are below. If you feel your work has been wrongly evaluated, please contact me directly.

100% Implements all requested functionality as specified in the instructions. Results are identical to expected results. Code is well organized and commented, and Haskell functions have explicit type declarations.

85%-99% Implements all requested functionality but loses points for style or very minor functionality issues. "Very minor" is subjective, but could refer to situations where the student clearly understands the concepts being dealt with but has overlooked some detail in the implementation. Unnecessarily verbose or complex solutions will also fall into this category. In the case of Haskell, otherwise correct function definitions without type declarations may fall into this category.

50%-85% Mostly works and follows the instructions but has significant functionality issues: e.g. appears to work but returns the wrong answer (in more than minor details), breaks or fails to return on some expected input values, etc. (If the program works but breaks on unexpected input, it will be noted whether students were required to implement exception handling of any kind. If not, it is assumed that input should be limited to expected values, and points are not docked for breaking on bad input. Prolog programs' behavior after pressing the semicolon falls into this gray area).

10%-50% Some required functionality is correctly or near-correctly implemented. E.g., a required predicate or function is implemented correctly, but issues elsewhere in the program make the program fail (including failing to compile) overall. If your program fails to compile (i.e. cannot be consulted, in the case of Prolog) you should expect your grade to fall in this range, at best.

0%-%10 Program has no redeeming components; student wrote essentially no code, or code that is not clearly recognizable as the correct language. Code may fail to compile or may compile trivially. (Partial credit under %10 may include, for example, syntactically correct, originally-named predicate or function definitions without rule bodies or content, or well-formed Haskell type declarations without associated functions defined.)​​

Online resources

The class Moodle page will be where you can turn in assignments and find some class materials.

Required software resources

You will need runtime environments for Prolog and Haskell.

Prolog:

SWI Prolog is the version of Prolog I use and recommend, and it's the version you should probably use. You can install a copy on your own computer as well. Please take a look at the instructions on Homework 1 for instructions on installing on OS X using Homebrew. The default installation method for OS X described on the SWI homepage does not work well with recent versions of OS X.

SWISH is a browser-based implementation of SWI Prolog that you can use without downloading anything. All of the assignments in this class should run in this environment.

Haskell:

Haskell.org is the online headquarters for Haskell. You'll find a lot of resources there, including a basic browser-based interpreter, the Haskell language definition, the Hoogle search engine of Haskell functions, and a list of tutorials.

You can download the Haskell Platform there to install on your own machine.

Supplemental resources

The following resources are not essential but may be interesting if you wish to deepen your understanding of the theory behind Prolog and Haskell.

First-Order Predicate Logic:

Predicate Logic by Martin Henz and Aquinas Hobor is a good quick introduction to first order predicate logic.

Logic, Language, and Meaning, Vol. 1: Introduction to Logic, L.T.F. Gamut. These books (vols 1 & 2) are particularly geared towards the linguistic and philosophical ramifications of formal logic, but they cover a lot of relevant ground in an accessible way. Volume 1 covers propositional and predicate calculus.

Lambda Calculus:

A Tutorial Introduction to the Lambda Calculus is a nice and brief introduction by Raúl Rojas.

Logic, Language, and Meaning, Vol. 2: Intensional Logic and Logical Grammar, L.T.F. Gamut. The second volume of this pair gets into the more advanced territory of higher order logic and lambda calculus.

Category Theory:

Category Theory for Computing Science is a freely available introduction to category theory, the mathematical theory that underlies much of the design and functionality of Haskell.

Category Theory for Programmers is an extended web tutorial by Bartosz Milewski intended as an accessible introduction to category theory.

Haskell/Category Theory is a Wikibook providing a brief overview of category as it pertains specifically to Haskell.


Portions of this syllabus and course are based on materials developed by Brad Richards.