CS 331 Spring 2025: Programming Languages


CS 331 Spring 2025
Programming Languages

Department: Computer Science, UAF
Instructor: Glenn G. Chappell
Office: 539 Duckering
Office Hours: In person 1–2 pm MWF, 3:30–4 pm MW on spring 2025 class days, or by appointment; private Zoom meetings available on request
E-mail: ggchappell@alaska.edu

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 28–May 2
  • May 2: Final Exam 1–3 pm in the classroom
  • Apr 28: Course wrap-up
    Slides [PDF]
   
Week 14
Apr 21–Apr 25
  • Online Quiz 13—on Canvas
    Due 5 pm Sun, Apr 27
 
Week 13
Apr 14–Apr 18
  • Apr 18: Prolog: interaction
    Slides [PDF]
    Instructor’s presentation
    Slides [Google Slides]
  • Apr 16: Prolog: flow of control
    Slides [PDF]
  • Apr 14: Prolog: lists
    Slides [PDF]
  • interact.pl [Prolog source]
    Code from Apr 18—Prolog: interaction
  • flow.pl [Prolog source]
    Code from Apr 16—Prolog: flow of control
  • check_fulmar.fmar [Fulmar source]
    A Fulmar program to run
    Used in Assignment 7, Exercise A
  • list.pl [Prolog source]
    Code from Apr 14—Prolog: lists
  • guess.fmar [Fulmar source]
    Fulmar demo: number guessing game
  • isort.fmar [Fulmar source]
    Fulmar demo: Insertion Sort
  • collatz.fmar [Fulmar source]
    Fulmar demo: Collatz sequences
  • fibo.fmar [Fulmar source]
    Fulmar demo: compute Fibonacci numbers
  • hello.fmar [Fulmar source]
    Hello-world in Fulmar
Week 12
Apr 7–Apr 11
  • Apr 11: Prolog: simple programming
    Slides [PDF]
  • Apr 9: PL category: logic PLs; introduction to Prolog
    Slides [PDF]
  • Apr 7: Thoughts on Assignment 6; unit overview—the Prolog programming language; PL feature: execution model
    Slides [PDF]
  • simple.pl [Prolog source]
    Code from Apr 11—Prolog: simple programming
  • fibo.pl [Prolog source]
    Compute Fibonacci numbers
  • hello.pl [Prolog source]
    Hello-world in Prolog
  • fulmar.lua [Lua source]
    REPL/shell for Fulmar programming language
    Requires lexit.lua, parseit.lua, interpit.lua
  • interpit_test.lua [Lua source]
    Test program for module interpit
    Used in Assignment 6, Exercise B
  • interpit.lua [Lua source] SKELETON
    Interpret AST from parseit.parse
    Solution to Assignment 6, Exercise B
Week 11
Mar 31–Apr 4
  • Apr 4: Writing an interpreter
    Slides [PDF]
  • Apr 2: Specifying semantics; how interpreters work
    Slides [PDF]
  • Mar 31: Scheme: macros (cont’d); 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)
Week 10
Mar 24–Mar 28
  • Mar 28: Scheme: macros
    Slides [PDF]
  • Mar 26: Scheme: data
    Slides [PDF]
  • Mar 24: Scheme: evaluation
    Slides [PDF]
  • macro.scm [Scheme source]
    Code from Mar 28 & 31—Scheme: macros
  • data.scm [Scheme source]
    Code from Mar 26—Scheme: data
  • eval.scm [Scheme source]
    Code from Mar 24—Scheme: evaluation
Week 9
Mar 17–Mar 21
  • Mar 21: Scheme: basics
    Slides [PDF]
  • Mar 19: Thoughts on Assignment 5; PL category: Lisp-family PLs; introduction to Scheme
    Slides [PDF]
  • Mar 17: 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 21—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 10–Mar 14
 
Week 8
Mar 3–Mar 7
  • Mar 7: Midterm Exam in class
  • Mar 5: Haskell: data (cont’d)
    Slides [PDF]
  • Mar 3: Haskell: I/O (cont’d); Haskell: data
    Slides [PDF]
 
Week 7
Feb 24–Feb 28
  • Feb 28: Haskell: I/O
    Slides [PDF]
  • Feb 26: Haskell: flow of control
    Slides [PDF]
  • Feb 24: Haskell: functions; Haskell: lists
    Slides [PDF]
  • io.hs [Haskell source]
    Code from Feb 28 & Mar 3—Haskell: I/O
  • flow.hs [Haskell source]
    Code from Feb 26—Haskell: flow of control
  • list.hs [Haskell source]
    Code from Feb 24—Haskell: lists
  • func.hs [Haskell source]
    Code from Feb 24—Haskell: functions
  • curry.cpp [C++ source]
    Curring in C++
Week 6
Feb 17–Feb 21
  • Feb 21: PL category: functional PLs; introduction to Haskell
    Slides [PDF]
  • Feb 19: Parsing wrap-up; thoughts on Assignment 4; unit overview—the Haskell programming language; PL feature: type system
    Slides [PDF]
  • Feb 17: Shift-reduce parsing
    Slides [PDF]
  • fibo.hs [Haskell source]
    Compute Fibonacci numbers
  • hello.hs [Haskell source]
    Hello-world in Haskell
  • use_parseit.lua [Lua source]
    Simple main program for parseit module
    Requires parseit.lua
  • parseit_test.lua [Lua source]
    Test program for module parseit
    Used in Assignment 4, Exercise A
  • parseit.lua [Lua source] SKELETON
    Solution to Assignment 4, Exercise A
    Requires lexit.lua
  • Shift-Reduce Parsing Table [PDF]
    Used in class Mon, Feb 17
Week 5
Feb 10–Feb 14
  • Feb 14: Recursive-descent parsing (cont’d)
    Slides [PDF]
  • Feb 12: Thoughts on Assignment 3; recursive-descent parsing (cont’d)
    Slides [PDF]
  • Feb 10: State-machine lexing (cont’d); 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 3–Feb 7
  • Feb 7: State-machine lexing (cont’d)
    Slides [PDF]
  • Feb 5: The basics of lexical analysis; state-machine lexing
    Slides [PDF]
  • Feb 3: 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 5
  • 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
  • adv.lua [Lua source]
    Code from Feb 3—Lua: advanced flow
Week 3
Jan 27–Jan 31
  • Jan 31: Lua: objects
    Slides [PDF]
  • Jan 29: Lua: fundamentals; Lua: modules
    Slides [PDF]
  • Jan 27: PL category: dynamic PLs; introduction to Lua
    Slides [PDF]
  • closure.cpp [C++ source]
    C++ Closures
  • obj.lua [Lua source]
    Code from Jan 31—Lua: objects
    Requires pets.lua
  • pets.lua [Lua source]
    Code from Jan 31—Lua pets module
  • mod.lua [Lua source]
    Code from Jan 29—Lua: modules
    Requires mymodule.lua
  • mymodule.lua [Lua source]
    Code from Jan 29—example Lua module
  • fund.lua [Lua source]
    Code from Jan 29—Lua: fundamentals
  • fibo.lua [Lua source]
    Compute Fibonacci numbers
  • hello.lua [Lua source]
    Hello-world in Lua
  • array_func.cpp [C++ source]
    Demo of array of functions in C++
Week 2
Jan 20–Jan 24
  • Jan 24: [OPTIONAL class meeting via Zoom; video on Canvas] Programming language syntax specification; unit overview—the Lua programming language; introduction to survey of programming languages; PL feature: compilation & interpretation
    Slides [PDF]
  • Jan 22: Context-free languages; thoughts on Assignment 1
    Slides [PDF]
  • Jan 20: No class meeting (AK Civil Rights Day)
Week 1
Jan 13–Jan 17
  • Jan 17: Regular languages & regular expressions
    Slides [PDF]
  • Jan 15: The Chomsky Hierarchy; regular languages
    Slides [PDF]
  • Jan 13: 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 19
  • Jan 13: 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 17 and due at 5 pm on Sunday, January 19.

External links last checked 2025-03-23.
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.
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.
Haskell 2010 Language Report [PDF]
The official published Standard for the Haskell programming language.
Python Full Grammar Specification
The parsing expression grammar that specifies the syntax of the latest version of the Python programming language.
Python Lexical Structure
The official documentation on the lexical structure of Python.
Lua 5.2 Reference Manual
The official Lua reference manual. At the bottom of the page is a grammar for Lua.
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.
Identifiers, Values, and Variables
My introduction to programming-language identifiers, values, and related terminology.
Reflection in Programming
My very short introduction to reflection.
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.