CMSI 3801
Exam 1 Preparation

When

Tuesday, October 7, 2025, last 45 minutes of class.

Scope

The study of programming languages, Language classification, Values, Entities, Binding, Expression Evaluation, Control Flow, Types, Lua, Python, JavaScript, TypeScript.

Ground Rules

In person, closed book and notes and devices and other people. No signaling answers. And so on. You have to work in a bubble.

Preparation Checklist

Do each of the following to maximize your preparation:

Were you able to check off every box?

An Outline of Course Content So Far

The fact that active recall is better for acquiring long-term knowledge does not mean that outlines and concept maps are not useful. Learners should use multiple techniques—think “both and” rather than “either or.”

The Study of Programming Languages
    Sum of even squares in many languages
    Why study programming languages?
    How to study programming languages (5 areas)
        History
            Major eras
        Languages
            Which are significant?
            What was the motivation for each?
        Conceptual Areas
            Language, Information, Computation
            Statics
            Dynamics
                Control Flow
                Concurrency
            Types
        Foundations
            Logic, Type Theory, λ Calculus, Computation Theory, Syntax, Semantics
        Pragmatics
            Vision and Values
            Criteria for Evaluation
            Expressiveness
            Popularity
    Classifying Programming Languages
        Types
            Machine, assembly, high-level, system, scripting, esoteric
        Paradigms
            Imperative, declarative, functional, logic, object-oriented, ...
Values
    Numbers
    Symbols (Atoms)
    Characters
        vs Graphemes
    Tuples
    Sequences (Lists)
        Strings
    Records
    Sets
    Dictionaries
    References
Entities
    Literals
    Variables
        Variables are the boxes, not the names, not the contained values
        Mutability
    Expressions
        Operators
    Statements
    Functions
        Function values vs function declarations
        Parameters vs arguments
        Procedures, consumers, suppliers, predicates
        Filtering
        Argument labels, kwargs, pattern matching
    Generators
        Finite
        Infinite
    Classes
        Objects
        Constructors, fields, methods
        Freezing
        Information hiding
    Modules
Control Flow
    Sequential Flow
    Conditional Flow
    Iterative Flow
    Recursion
    Nondeterministic Flow
    Disruption
Binding
    Examples of entities
    Examples of names
    Declarations vs definitions
    Assignments vs bindings
    Polymorphism vs aliasing
        Polymorphism: one name for multiple entities
        Aliasing: multiple names for one entity
    Static vs dynamic polymorphism
    Pointers
    Scope
        Static scope
        Dynamic scope
    Lifetime
        Entities outliving bindings
        Bindings outliving entities
        Preventing dangling references
            Garbage collection
            Disallowing references to locals
            Disallowing explicit deallocation
            Lexical closures
    Deep vs shallow binding
Expression Evaluation
    Expression examples
    Operator precedence
    Operator associativity
    Operator fixity
    Operator arity
    Evaluation order
        Defined order
        Undefined order
        Short-circuit evaluation
    Side effects
        Lvalues and rvalues
        Initialization vs assignment
    Lazy evaluation
    Macros
Control Flow
    Sequencing
        Of Expressions
        Of Statements
    Selection
        If-elseif-elsif-else
        Switch/Match/Case/When
        Fallthrough (ugh)
        Modifiers at end of statement
    Iteration
        Loops
            Loop forever
            Loop n times
            Loop while/until
            Loop through range (of numbers)
            Loop through a collection
            Fancy loop constructs
                Exiting from middle of a loop
                Restarting loops
        Each-functions
        Iterator objects
        Recursion
            Differences from (explicit) iteration
            Advantages and disadvantages
            Memoization
            Tail recursion
    Nondeterminism
    Disruption
        Goto
        Exceptions
        Loop disruption
Types
    The intuition behind types
    Type Theory
        An alternative to set theory
        Individuals brought into existence as inhabitants of types
            How we defined Nat, Bool, Int, Rat, PrimaryColor, Shape
            Tuples
            Lists
            Options
            Void
        How to define functions
        Lambda notation
    Subtypes
    Union types
    Intersection types
    Sums, products, and exponentials (functions)
    How programming languages define types
    Static vs Dynamic Types
        Static types are checked by the compiler
        Dynamic types are checked at run time
    Parameterized (Generic) Types
    Type equivalence and compatibility
        Nominal vs Structural
        Subtyping
        Coercion
            When should coercion be allowed?
    Static vs Dynamic
    Strong vs Weak
    Manifest vs Implicit
    Type Inference
        Four approaches:
            No inference, everything manifest
            Local variable inference only
            Hindley-Milner
            Control-flow assisted
    Pragmatics
Lua
    1993, Roberto Ierusalimschy et al
    Super small, very dynamic, scripting language
    Used in a lot of famous games
    Very few features
    Numbers, strings, booleans, nils have value semantics
    All other types have reference semantics
    Functions can have multiple results
    error() to throw, and pcall() to catch
    Tables are the only data structure
        Iterate with ipairs() and pairs()
        Indexing starts at 1
    Uses metatables to simulate user-defined types
        Metatable has 20+ methods
        Special __index method is for custom behaviors
    Coroutines are frequently used
JavaScript
    1995, Brendan Eich, probably most popular language
    First implementation was in 10 days
        Rushed because Java was failing in browser
    Very dynamic, scripting language
    Beautifully expressive but has a lot of WAT
    Great language for interactive programming
        Designed to support functional programming
        Event/Async features are built in
    Absolutely loaded with features
        Selective mutability (let vs. const)
        Pattern matching
        Destructuring
        Default parameters
        Rest parameters
        Shorthand properties
        Computed properties
        Higher-order functions
        Closures
        Generators
        Spreads
        Promises
        Async/Await
    8 Dynamic Types and No Static Types
        Undefined, Null, Boolean, Number, BigInt, String, Symbol, Object
        Arrays and functions are considered objects
        Can often use .constructor to additional type information
    Two number types
        number is IEEE 754 binary64
        bigint is arbitrary precision integer
    Has both null and undefined
    Very weak typing, most everything is convertible implicitly
        falsy values: undefined, null, false, 0, NaN, empty string
        nullish values: null, undefined
    Arrow vs non-arrow functions
    this
    Class syntax is just syntactic sugar for functions and prototypes
    Ecosystem with NPM
Python
    1991, Guido van Rossum
    Easy to learn, read, and write
    Things generally work as expected
    Winning in data science, machine learning, etc
    EVERYTHING is an object (seriously)
    Variables only store references (seriously)
    Indentation-sensitive syntax
    Tons of dynamic types but there is syntax for type hints
        Type hints checked by a pre-processor (e.g. MyPy) and ignored at runtime
    So many types
        ints are unbounded, floats are IEEE 754 binary64
        complex numbers
        strings
        bytes
        lists
        tuples
        sets
        dictionaries
        ranges
        functions
        classes
        modules
        None
        booleans
        exceptions
    Some collections are mutable, some are not
    Falsy values are None, False, 0, 0.0, 0j, Decimal(0), Fraction(0, 1), [], (), {}, '', set(), range(0), and you can make your own
    Variable declaration is just assignment
    Loved for having those comprehensions
    Classes are real types
    Lots of convenient syntactic forms
        [x:y:z]
        / and * in parameter lists
        positional and keyword arguments
        *args and **kwargs
        packing and unpacking
        f-strings
    Iterators and generators
    Special methods like __init__ and __str__
    Operator overloading (e.g. __add__)
TypeScript
    2012
    JavaScript with types
    All JavaScript programs are TypeScript programs
    TypeScript is a kind of preprocessor—TS code is transpiled to JS
    Type inference that is control flow assisted
    The dynamic types are the same as in JS (for obvious reasons!)
    The (important) static types:
        number, bigint, boolean, symbol, string, null, undefined
        void, never, unknown
        Unions, Intersections, Literal types
        Tuples, Arrays, Functions
        Objects, Interfaces
        Generics
        Generator, Iterable
    Classes
        Properties and methods
            Can have access modifiers
            Can be static
            Can be marked with a "?"
        Constructors
        Inheritance
    Type aliases
        Differences between aliases and interfaces
    Covariance of arrays
    “Optionals” as Unions with undefined
    Type compatibility
    Type erasure
    Type narrowing
        Control-flow based type analysis
        Can narrow types with instanceof
        Can narrow types with typeof
        Can narrow types with in
        Assertion functions
        Type guards
    Type assertions

Format of the Exam

An ideal assessment of your understanding of programming language concepts would examine your fluency with the course material through an oral exam. However, given the the number of students, this assessment will be on your recognition and evaluation of concept expression in the form of multiple choice and similar questions.

You will have 45 minutes to complete the exam. Paper will be provided to you on which you’ll write your answers. But you do need to bring your own writing implements.

About the Problems

There will be 20 questions of the multiple choice, multiple select, fill-in-the-blank, and short answer variety.

During the class period one week prior to the exam, we will go over the context for each of the 20 problems. This will enable you to focus your studying on the right areas.