CS 331 Spring 2026: Programming Languages


CS 331 Spring 2026
Programming Languages

Department: Computer Science, UAF
Instructor: Glenn G. Chappell
Office: 539 Duckering
Office Hours:  In person 3:30–4:30 pm MW, 1:15–3:15 pm T, 1:15–2:15 pm Th on spring 2026 class days, or by appointment; private Zoom meetings available on request 
E-mail: ggchappell@alaska.edu
Zoom for presentations (passcode sent via e-mail): https://alaska.zoom.us/j/82013470406.

Announcements

Course Materials

Materials are listed with the most recent at the top.

Week Class Meetings Readings & Homework Handouts & Code
See Git repository for code
Week 15
& Finals
Apr 27–May 1
  • Apr 29: Final Exam 3:15–5:15 pm in the classroom
  • Apr 27: Course wrap-up
    Slides [PDF]
   
Week 14
Apr 20–24
  • Online Quiz 13—on Canvas
    Due 5 pm Sun, Apr 26
Week 13
Apr 13–17
  • Apr 17: Prolog: interaction; thoughts on presenting
    Slides [PDF]
    Instructor’s presentation
    Slides [Google Slides]
  • Apr 15: Prolog: flow of control
    Slides [PDF]
  • Apr 13: Prolog: lists
    Slides [PDF]
  • interact.pl [Prolog source]
    Code from Apr 17—Prolog: interaction
  • flow.pl [Prolog source]
    Code from Apr 15—Prolog: flow of control
  • check_tamandua.tdua [Tamandua source]
    A Tamandua program to run
    Used in Assignment 7, Exercise A
  • guess.tdua [Tamandua source]
    Tamandua demo: number guessing game
  • isort.tdua [Tamandua source]
    Tamandua demo: Insertion Sort
  • collatz.tdua [Tamandua source]
    Tamandua demo: Collatz sequences
  • fibo.tdua [Tamandua source]
    Tamandua demo: compute Fibonacci numbers
  • hello.tdua [Tamandua source]
    Hello-world in Tamandua
  • list.pl [Prolog source]
    Code from Apr 13—Prolog: lists
Week 12
Apr 6–10
  • Apr 10: Prolog: simple programming
    Slides [PDF]
  • Apr 8: PL category: logic PLs; introduction to Prolog
    Slides [PDF]
  • Apr 6: Thoughts on Assignment 6; unit overview—the Prolog programming language; PL feature: execution model
    Slides [PDF]
  • simple.pl [Prolog source]
    Code from Apr 10—Prolog: simple programming
  • fibo.pl [Prolog source]
    Compute Fibonacci numbers
  • hello.pl [Prolog source]
    Hello-world in Prolog
  • tamandua.lua [Lua source]
    REPL/shell for Tamandua programming language
    Requires lexit.lua, parseit.lua, interpit.lua
  • interpit_test.lua [Lua source]
    Test program for module interpit
    Used in Assignment 6, Exercise A
  • interpit.lua [Lua source] SKELETON
    Interpret AST from parseit.parse
    Solution to Assignment 6, Exercise A
Week 11
Mar 30–Apr 3
  • Apr 3: Writing an interpreter
    Slides [PDF]
  • Apr 1: Specifying semantics; how interpreters work
    Slides [PDF]
  • Mar 30: Scheme: macros II; unit overview—semantics & interpretation; introduction to semantics
    Slides [PDF]
  • calculator.lua [Lua source]
    REPL for evaluator.lua
    Requires lexer.lua, rdparser3.lua, evaluator.lua
  • evaluator.lua [Lua source]
    Evaluator for arithmetic expression AST (rdparser3.lua format)
  • macro2.scm [Scheme source]
    Code from Mar 31—Scheme: macros II
Week 10
Mar 23–27
  • Mar 27: Scheme: macros I
    Slides [PDF]
  • Mar 25: Scheme: data
    Slides [PDF]
  • Mar 23: Scheme: evaluation
    Slides [PDF]
  • macro1.scm [Scheme source]
    Code from Mar 27—Scheme: macros I
  • data.scm [Scheme source]
    Code from Mar 25—Scheme: data
  • eval.scm [Scheme source]
    Code from Mar 23—Scheme: evaluation
Week 9
Mar 16–20
  • Mar 20: Scheme: basics
    Slides [PDF]
  • Mar 18: Thoughts on Assignment 5; PL category: Lisp-family PLs; introduction to Scheme
    Slides [PDF]
  • Mar 16: Comments on the Midterm Exam; where are we?; unit overview—the Scheme programming language; PL feature: identifiers & values; PL feature: reflection; about the presentation
    Slides [PDF]
  • basic.scm [Scheme source]
    Code from Mar 20—Scheme: basics
  • fibo.scm [Scheme source]
    Compute Fibonacci numbers
  • hello.scm [Scheme source]
    Hello-world in Scheme
  • pa5_test.hs [Haskell source]
    Test program for Assignment 5 functions & variables
    Used in Assignment 5, Exercise B
  • PA5.hs [Haskell source] SKELETON
    Skeleton version of answers to Assignment 5, Exercise B
  • check_prolog.pl [Prolog source]
    A Prolog program to run
    Used in Assignment 5, Exercise A
  • reflect.scm [Scheme source]
    Very simple Scheme reflection
Spring Break
Mar 9–13
 
Week 8
Mar 2–6
  • Mar 6: Midterm Exam in class
  • Mar 4: Haskell: data (cont’d)
    Slides [PDF]
  • Mar 2: Haskell: I/O II; Haskell: data
    Slides [PDF]
 
  • bestnum.hs [Haskell source]
    Second CS I program in Haskell
  • data.hs [Haskell source]
    Code from Mar 2 & 4—Haskell: data
  • squarenums.hs [Haskell source]
    Computer Science I program in Haskell
  • io2.hs [Haskell source]
    Code from Mar 2—Haskell: I/O II
Week 7
Feb 23–27
  • Feb 27: Haskell: I/O I
    Slides [PDF]
  • Feb 25: Haskell: flow of control
    Slides [PDF]
  • Feb 23: Haskell: functions; Haskell: lists
    Slides [PDF]
  • io1.hs [Haskell source]
    Code from Feb 27—Haskell: I/O I
  • Exam Review Problems, Set C
  • Exam Review Problems, Set B
  • Exam Review Problems, Set A
  • flow.hs [Haskell source]
    Code from Feb 25—Haskell: flow of control
  • list.hs [Haskell source]
    Code from Feb 23—Haskell: lists
  • func.hs [Haskell source]
    Code from Feb 23—Haskell: functions
  • curry2.cpp [C++ source]
    Currying in C++
  • curry.swift [Swift source]
    Currying in Swift
Week 6
Feb 16–20
  • Feb 20: PL category: functional PLs; introduction to Haskell
    Slides [PDF]
  • Feb 18: Parsing wrap-up; thoughts on Assignment 4; unit overview—the Haskell programming language; PL feature: type system
    Slides [PDF]
  • Feb 16: Shift-reduce parsing
    Slides [PDF]
  • fibo.hs [Haskell source]
    Compute Fibonacci numbers
  • hello.hs [Haskell source]
    Hello-world in Haskell
  • parseit_test.lua [Lua source]
    Test program for module parseit
    Used in Assignment 4, Exercise A
  • use_parseit.lua [Lua source]
    Simple main program for parseit module
    Requires parseit.lua
  • parseit.lua [Lua source] SKELETON
    Solution to Assignment 4, Exercise A
    Requires lexit.lua
  • Shift-Reduce Parsing Table [PDF]
    Used in class Mon, Feb 16
Week 5
Feb 9–13
  • Feb 13: Recursive-descent parsing III
    Slides [PDF]
  • Feb 11: Thoughts on Assignment 3; recursive-descent parsing II
    Slides [PDF]
  • Feb 9: State-machine lexing III; the basics of syntax analysis; recursive-descent parsing
    Slides [PDF]
  • use_rdparser3.lua [Lua source]
    Simple main program for rdparser3 module
    Requires rdparser3.lua
  • rdparser3.lua [Lua source]
    Recursive-descent parser #3: expressions
    Requires lexer.lua
  • use_rdparser2.lua [Lua source]
    Simple main program for rdparser2 module
    Requires rdparser2.lua
  • rdparser2.lua [Lua source]
    Recursive-descent parser #2: more complex
    Requires lexer.lua
  • lexit_test.lua [Lua source]
    Test program for module lexit
    Used in Assignment 3, Exercise B
  • use_lexit.lua [Lua source]
    Simple main program for lexit module
    Requires lexit.lua
  • check_scheme.scm [Scheme source]
    A Scheme program to run
    Used in Assignment 3, Exercise A
  • use_rdparser1.lua [Lua source]
    Simple main program for rdparser1 module
    Requires rdparser1.lua
  • rdparser1.lua [Lua source]
    Recursive-descent parser #1: simple
    Requires lexer.lua
Week 4
Feb 2–6
  • Feb 6: State-machine lexing II
    Slides [PDF]
  • Feb 4: The basics of lexical analysis; state-machine lexing I
    Slides [PDF]
  • Feb 2: Lua: advanced flow; thoughts on Assignment 2; unit overview—lexing & parsing; introduction to lexing & parsing
    Slides [PDF]
  • use_lexer.lua [Lua source]
    Simple main program for lexer module
    Requires lexer.lua
  • lexer.lua [Lua source]
    In-class lexer module
  • In-class lexical specification [PDF]
    Used in class starting Wed, Feb 4
  • adv.lua [Lua source]
    Code from Feb 2—Lua: advanced flow
  • pa2_test.lua [Lua source]
    Test program for Assignment 2 functions
    Used in Assignment 2, Exercise B
  • check_haskell.hs [Haskell source]
    A Haskell program to run
    Used in Assignment 2, Exercise A
  • Coding Standards
Week 3
Jan 26–30
  • Jan 30: Lua: objects
    Slides [PDF]
  • Jan 28: Lua: modules
    Slides [PDF]
  • Jan 26: PL category: dynamic PLs; introduction to Lua
    Slides [PDF]
  • closure2.cpp [C++ source]
    C++ Closures
  • closure.swift [Swift source]
    Swift Closures
  • obj.lua [Lua source]
    Code from Jan 30—Lua: objects
    Requires pets.lua
  • pets.lua [Lua source]
    Lua pets module
  • mod2.lua [Lua source]
    Code from Jan 28—Lua: modules, part II
    Requires mymodule.lua
  • mymodule.lua [Lua source]
    Example Lua module
  • mod1.lua [Lua source]
    Code from Jan 28—Lua: modules, part I
  • fibo.lua [Lua source]
    Compute Fibonacci numbers
  • hello.lua [Lua source]
    Hello-world in Lua
  • func_array2.cpp [C++ source]
    Demo of array of functions in C++
  • func_array.swift [Swift source]
    Demo of array of functions in Swift
  • sum_last2.pl [Perl source]
    Output the sum of the last word on each line
    Demo of Perl
  • sum_last.awk [AWK source]
    Output the sum of the last word on each line
    Demo of AWK
Week 2
Jan 19–23
  • Jan 23: Programming language syntax specification; unit overview—the Lua programming language; introduction to survey of programming languages; PL feature: compilation & interpretation
    Slides [PDF]
  • Jan 21: Context-free languages; thoughts on Assignment 1
    Slides [PDF]
  • Jan 19: No class meeting (AK Civil Rights Day)
  • Programming Languages Survey [Google Forms]
    Used in Assignment 1, Exercise B
  • check_lua.lua [Lua source]
    A Lua program to run
    Used in Assignment 1, Exercise A
Week 1
Jan 12–16
  • Jan 16: Regular expressions
    Slides [PDF]
  • Jan 14: The Chomsky Hierarchy; regular languages
    Slides [PDF]
  • Jan 12: Course overview; unit overview—formal languages & grammars; basic concepts; introduction to formal languages & grammars
    Slides [PDF]
  • Online Quiz 1—on Canvas
    Due 5 pm Sun, Jan 18
  • Jan 12: Read “Compilers and Interpreters”.
    The above date is when the reading is assigned. Each reading is to be completed before taking the next quiz—in this case, Online Quiz 1, which will be posted on Friday, January 16 and due at 5 pm on Sunday, January 18.
  • regex2.py [Python 3 source]
    Demo of regular expressions in Python
  • regex.swift [Swift source]
    Demo of regular expressions in Swift
  • In-Class Worksheet 1: Grammars, DFAs [PDF]
    Distributed in class Wed, Jan 14
  • type_error2.py [Python 3 source]
    Example of type error in Python
  • type_error.swift [Swift source]
    Example of type error in Swift
  • Semester Plan
    Updated Mon, Mar 23
  • Syllabus
    Distributed in class Mon, Jan 12

External links last checked 2026-04-01.
Git
Git is the the version-control software used in this class. This site includes downloads and a helpful tutorial.
Learn Git Branching
An excellent tutorial. If you are familiar with the Git operations clone, pull, push, add, and commit, but you are having trouble wrapping your head around branching, then this is for you.
Class Git Repository
Source code for the class will be kept in this repository.
Language Reference from The Swift Programming Language
The book that include the offical specification of the Swift programming language.
Python Lexical Structure
The official documentation on the lexical structure of Python.
Python Full Grammar Specification
The parsing expression grammar that specifies the syntax of the latest version of the Python programming language.
Lua 5.2 Reference Manual
The official Lua reference manual. The lexical structure is covered in Section 3.1. A grammar for Lua is at the bottom of the page. Operator precedence is covered in Section 3.4.7.
Haskell 2010 Language Report [PDF]
The official published Standard for the Haskell programming language.
C++ language and library references
A collection of useful links on the cppreference.com site. It includes a link to the final working draft for each of the recent C++ Standards. Strictly speaking, this draft is not the actual Standard, but it might as well be.
C++ 2023 Standard Final Working Draft [PDF] warning: over 2000 pages long
The final working draft for the 2023 ISO C++ Standard. The only significant difference between this document and the official published C++ Standard is that the latter has the “working draft” wording removed.
Revised7 Report on the Algorithmic Language Scheme
The current official Scheme specification. The main page has links to other forms of the report.
Links to supplemental readings will be posted here as they are assigned. Links to these will also be in the “Readings & Homework” column of the Course Materials section, above.
Compilers and Interpreters
A short article I wrote about the different kinds of programs that allow us to execute code.
LuaTutorial
A nice tutorial on the Lua programming language. Part of the Lua-Users Wiki, a site chock full of information about Lua. The assigned reading is the first 9 sections: LuaTypesTutorial through ScopeTutorial. However, the whole tutorial is worthwhile, I think.
A Primer on Type Systems
My introduction to type systems, types, and associated concepts.
Learn Haskell in 10 minutes
A short introduction to Haskell, for people who already know something about programming, from HaskellWiki.
Reflection in Programming
My very short introduction to reflection.
Identifiers, Values, and Variables
My introduction to programming-language identifiers, values, and related terminology.
A Quick Introduction to Scheme
My introduction to the Scheme programming language. This uses DrRacket.
Programming-Language Execution Models
What task drives the execution of a program? What strategy is used to complete this task? This is a look at the answers to these questions for various PLs, including Prolog.
A Quick Introduction to Prolog
My introduction to the Prolog programming language. This uses SWI-Prolog.
Wikipedia Page on Operational Semantics
This page contains examples of the standard notation for “small-step” operational semantics.