COMP 212: Functional Programming

Dan Licata Spring, 2024

Objectives

The purpose of this course is to introduce the theory and practice of functional programming (FP). The characteristic feature of FP is the emphasis on computing by calculation. The traditional distinction between program and data characteristic of imperative programming (IP) is replaced by an emphasis on classifying expressions by types that specify their behavior. Types include familiar (fixed and arbitrary precision) numeric types, tuples and records (structs), classified values (objects), inductive types such as trees, functions with specified inputs and outputs, and commands such as input and output. Execution of imperative programs is generalized to evaluation of well-typed expressions by a smooth extension of mathematical experience to programming practice.

The advantages of FP are significant:

By the end of the course, we expect you to:
  1. write functional programs
  2. analyze their sequential and parallel complexity
  3. reason mathematically about their behavior
  4. structure them using abstract types

Prerequisites: COMP 211. MA 228 (or some other math class if you're not ready for that yet) works well as a corequisite.

Activities

There will be two lectures per week. Lectures will be in Exley 121, Tuesday and Thursday 2:40-4:41pm. If you miss class or want to review, the (asynchronous) videos from a previous year's course are linked from the lectures page. There are also readings (lecture notes from a previous instance of this course). We may cover a bit of new material this semester that is not in these pre-recorded videos or notes, especially towards the end of the semester.

There will be weekly lab sessions held on Wednesday at 1:20pm-2:40pm in Olin 14 and 2:50pm-4:10pm in Olin 14. Labs are intended to be the bridge between lectures and homeworks: you practice the skills introduced in lecture, with help, to prepare you for the week’s homework. There will occaisonally be a bit of new material beyond the lecture content introduced in lab, and you are responsible for this material. Solutions will be posted after the labs, and some lab solutions will be discussed in the next day's lecture, so you should plan to do them before then to avoid spoilers. Because different students work at different rates, we do not expect everyone to finish all of the problems in the lab handout. We do expect you to put in a good-faith effort to work on the provided problems and learn something. Labs will be graded on a scale of 0/1: you will receive a 0 if you do not attend lab at all, you leave early, or you do not engage with the material. You will receive a 1 if you put in a good-faith effort and the TAs and I determine that you have made satisfactory progress. If you cannot attend a lab for some reason, you can do it on your own or at a TA session and upload your solution to get checked off.

There will be weekly written and programming assignments. Homeworks are designed to help you internalize the course material and are where most of the learning in the class happens; they consist of written problems and short to medium-sized programming tasks. Homeworks will be submitted by uploading them to a Google Drive folder. Late homeworks will only be accepted by permission of instructor (please ask if you need extra time!).

For assistance with the homeworks, there will be regular help sessions. Almost all students require some rapid, interactive feedback to learn programming and computer science, so we strongly recommend arranging your schedule so that you can do some of your homework at some of these sessions.

In place of exams, there will be non-collaborative challenge problems on many homeworks. These problems will test your proficiency with the material without help from the course staff.

Assessment

Your grade will be based on the homework assignments (95%) and lab/class participation (5%). Around 80% of the homework points will be from regular problems, and 20% will be from non-collaborative challenge problems. Each homework will be worth somewhere between 50 and 100 points depending on its length, all points (regular and challenge) are weighted equally, and your overall grade will depend on the total number of points received. Generally, 90%-100% should be interpreted as A work, 80-90% as B, 70-80% as C, 60-70% as D, and below that as failing. However, the instructor may adjust the final letter grade boundaries in either direction at the end of the semester, to account for differences between the intended and actual difficulty of the assignments. Assignments will be graded for correctness, clarity, and efficiency. You are allowed to take the course CR/U, in which case a D- or better is required for a transcript grade of CR. However, to use it the class to declare the COMP major, it must be taken for a grade, and you must get a C- or better.