CSE 341: Programming Languages
Course information and policies
This course is an introduction to functional programming (FP). We will cover statically typed FP in OCaml and dynamically typed FP in Racket. We will also relate FP to object oriented (OO) languages, and show how to simulate FP in OO and OO in FP. Along the way we will discuss the theory and design of programming languages.
This is a difficult time. The course will be taught entirely online via Zoom. We will record lectures and section for archival purposes, but real-time attendance is mandatory except in extenuating circumstances. Please get in touch to discuss any accommodations you may need to succeed in this course.
Staff
James Wilcox (he/him, they/them)
Jiuru Li (he/him)
Katie Lum (she/her)
Frank Qin (he/him)
Yihong Zhang (he/him, they/them)
Kevin Zhu (he/him)
Schedule
Section Th 11:30, 12:30, 1:30, and 2:30 (join Zoom by clicking the time corresponding to your section)
Grading
Approximately 6 homework assignments, combined worth 60% of final grade
Two "individual assignments", together worth 30% of final grade
Attendance and participation in lecture, section, office hours, and online discussion, worth the remaining 10%
No traditional exams, tests, or quizzes
Collaboration policy
You are encouraged to discuss the homework assignments with your classmates and to collaborate. However, the work you submit should be your own. Do not look directly at anyone else's work or solution. Do not show your work or solution to anyone else. If you work closely with another student, please include a note to that effect in your submission.
Attendance Policy
Real-time attendance at lecture and section is mandatory except in extenuating circumstances (eg, in a different timezone). If you must miss any of these, please notify all staff by email as soon as possible.
Late Policy
All assignments are due on some day at 5:59:59pm Pacific time. You have 5 late days to use throughout the quarter. Late days are indivisible, and each late day extends the deadline by 24 hours. In other words, if you submit at 6:00:00pm Pacific time on the due date (i.e., 1 second after the deadline), you are charged 1 whole late day and have until 5:59:59pm the next day to keep submitting without spending additional late days. Late days may not be used on "individual assignments".
Resources
Discussion on CSE Mattermost (invite link to create account)
Staff email list: cse341-staff@cs.washington.edu
Gradescope (add code: 9DWB6R)
Setting up OCaml environment:
Instructions to install the CSE VM (available to all students)
Once in the VM install OCaml by running sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) && opam init && eval $(opam env) in the terminal. Type 'y' when it asks to modify ~/.bash_profile.
SSH into attu (remote CSE Linux cluster, available to CSE students only): from terminal, ssh <CSENetID>@attu.cs.washington.edu , password is your CSE login password. attu has OCaml installed on it.
To use OCaml in the terminal (VM or attu): type ocaml to start the REPL, ocaml <OCaml file name> to execute an OCaml file, or ocamlc -o <output file name> <OCaml file name> to compile an OCaml file into an executable with the given output file name.
Going further
UW CSE505: Programming Languages (graduate-level course)
UW CSE490P: Advanced Programming Languages and Verification (advanced undergrad-level course, includes videos)
Software Foundations (graduate-level online textbook on programming languages, using the Coq proof assistant)
Types and Programming Languages by Benjamin Pierce (standard graduate-level textbook in programming languages)
Assignments
hw0 (due Monday 10/5 at 5:59:59pm Pacific time)
Fill out this survey.
Grab the starter code for hw0 and complete the TODOs. Turn in on Gradescope (see Resources above for the course add code).
hw1 (due Wednesday 10/14 at 5:59:59pm Pacific time)
Complete the problems described in the hw1 handout. Turn in on Gradescope as described in the handout.
If you're using attu, you will get errors about the Option module because of an old version of OCaml installed on the server. Follow these instructions (also available in video walkthrough) to install an up-to-date version of OCaml in your attu home directory.
Alternatively, you can download option.ml, put it under the same directory with your hw1.ml, and then run
ocaml option.ml hw1.ml
or, to compile, use ocamlc -o hw1 option.ml hw1.ml,
or type #mod_use "option.ml";; before your #use "hw1.ml" if you are using the REPL.
hw2 (due Friday, 10/23 at 5:59:59pm Pacific time)
Grab the starter code for hw2 and follow the handout to complete the problems. Turn in on Gradescope.
hw3 (due Monday, 11/2 at 5:59:59pm Pacific time)
Grab the starter code for hw3 and follow the handout to complete the problems. Turn in on Gradescope.
hw4 (due Thursday, 11/12 at 5:59:59pm Pacific time)
Grab the starter code for hw4 and follow the handout to complete the problems. Turn in on Gradescope.
hw5 (due Friday, 11/20 at 5:59:59pm Pacific time)
Grab the starter code for hw5 and follow the handout to complete the problems. Turn in on Gradescope.
hw6 (due Wednesday, 12/2 at 5:59:59pm Pacific time)
Grab the starter code for hw6 and follow the handout to complete the problems. Turn in on Gradescope.
hw7 (due Friday, 12/11 at 5:59:59pm Pacific time)
Grab the starter code for hw7 and follow the handout to complete the problems. Turn in on Gradescope.
Calendar
All videos (CSE netid or course enrollment required)
L01 (9/30): Welcome to 341! Intro to variable bindings in OCaml.
S1 (10/1): Editors, OCaml scoping
L02 (10/2): Syntax and semantics of variable bindings and expressions; intro to function bindings
L03 (10/5): Function bindings
L04 (10/7): Tuples and Lists
S2 (10/8): Type synonyms, datatypes, pattern matching, type generality
L05 (10/9): Local bindings, exponential efficiency, options, mutation and aliasing
L06 (10/12): Records, variants, and match expressions
L07 (10/14): More variants and match
S3 (10/15): More pattern matching, tail recursion
L08 (10/16): The truth about functions; Nested patterns
L09 (10/19): Tail recursion and exceptions
L10 (10/21): First-class and higher-order functions
S4 (10/22): Higher-order functions
L11 (10/23): Lexical Scope; Closures; Intro to Currying
L12 (10/26): Closure idioms; More Currying
L13 (10/28): Mutation; Modules
S5 (10/29): Currying, Modules
L14 (10/30): Type inference
L15 (11/2): Guest Lecture on Rust by Max Willsey
L16 (11/4): Racket
S6 (11/5): Racket Basics, Lists
L17 (11/6): Local bindings, pairs, set!, and mutable pairs
L18 (11/9): Thunks, promises, and streams
No class on 11/11
S7 (11/12): Streams, Macros
L19 (11/13): Macros
L20 (11/16): Untyped Lambda Calculus
L21 (11/18): Structs in Racket
S8 (11/19): Macros and Language Interpretation
L22 (11/20): Implementing Languages (including closures)
L23 (11/23): Guest Lecture on Dafny by Rustan Leino
Note: unlike most lectures, the slides and demo code from this lecture are protected with the same restrictions as the video recordings. Please contact the course staff if you have any questions.
L24 (11/30): Course motivation and Static vs. Dynamic Typing
L25 (12/2): Racket OO
S9 (12/3): Racket OOP, Pattern Matching, For Loops
L26 (12/4): Subclassing, Overriding, and Augmenting
Slides (Keynote); Slides (PDF); Demo code; video; supplemental optional video on pubment/augment (will rehash on Monday)
L27 (12/7): Dynamic dispatch
L28 (12/9): Functional vs Object-oriented decomposition, the Expression Problem, and Double Dispatch
S10 (12/10): Double Dispatch, Subtyping
L29 (12/11): Subtyping; Victory Lap