CMSI 3801
Final Exam Preparation

How to Prepare

Students best prepare for a final when they have certain things:

I would suggest going over the outlines below, making sure you understand each topic by going back over the course notes and the relevant sections in the textbook and associated course readings, where applicable. But don’t just re-read, cram, and highlight; test yourself with well-crafted, meaningful, and helpful questions. Hopefully you’ve been doing some spaced repetition learning along the way.

It may also be helpful to browse many of the course notes pages on material we did not cover. There is a ton of good stuff there. Sometimes this extra material might expose you to ways in which the basic material you did learn can be used in practice.

Glance over the course textbook, especially in the intro and summary sections for the languages we covered in class. It is filled with stuff I like to think about, and since I will be writing the final, well, it never hurts to have just a little more comfort with the things I feel are important.

Do reinforcement and practice problems.

Course Outline

Reviewing this outline will jog your memory. We had fun didn’t we?

  1. PROGRAMMING LANGUAGE PRACTICE
    • Reasons to study PL
    • How we studied PL
      • The idea is to learn concepts, but to do so by learning many languages
      • As we introduce each language, we compare to previous languages, and see concepts emerge
      • Major conceptual areas
        • Names (bindings, scope, declarations)
        • Types
        • Computations (expressions, statements)
        • Abstractions (routines, modules, objects)
        • Metaprogramming
    • Evaluation Criteria
    • Major Types of Programming Languages
      • Machine, Assembly, High-level, System, Scripting, Esoteric
    • Programming Paradigms
      • Imperative, Declarative, Structured, Functional, OO, and dozens more
  2. FIVE EXAMPLE LANGUAGES IN DEPTH
    1. JavaScript
      • Probably the most popular language in the world
      • Beautiful expressive core language buried in tons of crap
      • Often runs in browser (with HTML/CSS) but world of Node important for us
      • Module ecosystem features NPM, require
      • Test with Mocha
      • Eight types (Undefined, Null, Boolean, Number, BigInt, String, Symbol, Object)
      • Typing: DYNAMIC, WEAK
      • Truthy, falsy, and nullish
      • Primitives (with value semantics) vs. objects (with reference semantics)
      • Properties, property access, shorthand property notation
      • Pattern matching
      • Arrays and functions are objects
      • Arrow vs non-arrow functions
      • this
      • Constructors and Prototypes
      • Class is just syntactic sugar for constructors and prototypes
      • Functions with default parameters, rest parameters
      • Scope
      • let vs. const (and the old var)
      • Closures
      • Generators (implemented with closures or with function*)
      • Higher order functions
    2. Python
      • Very expressive, fun, things generally work as expected
      • Use Python 3, not Python 2
      • Typing: DYNAMIC, STRONG
      • Indentation (offside rule)
      • Lots and lots of types
      • id and type
      • Quite a few collections: lists, tuples, sets..., all work mostly the same way
      • Some are mutable, some are not
      • Default arguments
      • Positional vs Keyword arguments
      • Syntax for FORCING caller to use positional (/) or use keyword (*) args
      • Scope and Closures
      • Variable declarations different that JavaScript
      • List Comprehensions
      • Classes are real, unlike those things in JavaScript
      • Iterators
      • Generators
      • Classes
      • Special methods __init__, __str__
      • Inheritance
      • Operator overloading
    3. Java
      • An enterprise language
      • Only top-level construct is the class (uggh)
      • Eight primitive types, everything else is a reference type (array, class, interface, enum)
      • “Characters” are UTF-16 codes (uggh)
      • Typing: Static, Strong, Very Manifest (though var for locals and lambdas)
      • REPL is called JShell
      • Classes, Inheritance, Polymorphism
      • Variables have Types, Objects have Classes
      • Generics, but only for reference types (uggh)
      • Optionals
      • Lambdas
      • Streams: remember the three main parts!
        1. SOURCES (Arrays, collections, generator functions, files, ...)
        2. INTERMEDIATE OPERATIONS (map, filter, flatMap, distinct, sorted, limit, skip, ...)
        3. COLLECTORS (min, max, count, anyMatch, allMatch, findFirst, findAny>, reduce, forEach, ...)
      • Arrays are covariant (uggh)
      • Garbage Collection
    4. Swift
      • Arrived in 2014, primarily designed by Chris Lattner at Apple
      • Intended to be (1) safe, (2) fast, (3) powerful
      • All types are Structs, Classes, Enums, Tuples, Functions, Prototypes
      • Lots of number types (Int8, UInt8, Int16, UInt16, ..., Float, Double)
      • Unicode correct, with proper understanding of normalization and graphemes
      • Structs have value semantics, Classes have reference semenatics
      • Bool, Character, String, and the number types are actually structs!
      • [T] for array of T, [K:V] for dictionary
      • let for constants, var for mutable
      • let-immutability is deep!
      • Parameter names and argument labels
      • Functions are special cases of closures
      • Two syntaxes for closures: {x in x * 5} vs {$0 * 5}
      • Structs and classes have (1) properties, (2) methods, (3) initializers, (4) subscripts
      • Properties can be stored or computed
      • Recursive enums use indirect keyword
      • Generics
      • Optionals
      • if-let, while-let, guard-else
      • ?. ?[] ?() for option-chaining, and ?? (nil-coalescing operator)
      • Can throw if errors are recoverable
      • Operator overloading but ALSO custom operators (woo!)
      • Protocols (other types adopt protocols / conform to them)
      • Useful standard protocols: Equatable, Comparable
      • Extensions
      • Definitive Initialization
      • Separate operators for modular arithmetic
      • ARC
      • Weak references
    5. C++
      • Mostly a superset of C
      • Systems language: compiles to native code, no VM or runtime
      • C is too primitive; C++ adds classes, exceptions, and a rich library
      • Not garbage collected, but you use destructors to make things safer
      • Pointers are explicit
      • Must know static vs stack vs heap storage
      • Pointers to locals (careful!)
      • Typing: STATIC, MOSTLY WEAK
      • No REPL
      • Declarations vs Definitions
      • Declarators are crazy
      • Lots of numeric types (signed vs unsigned matters, bit size matters)
      • Structs
      • Allows you to do aliases with &
      • Has explicit pointers
      • Raw pointers vs smart pointers
      • Constructors, Destructors, and Assignment operators
      • Difference between move and copy
      • Rule of three, Rule of five
      • =default, =delete
      • Raw arrays vs. Standard Library arrays
      • Collections on the standard library: vector, map, etc.
      • Strings (char*, std::string)
      • Functions, function operator, lambdas (require explicit capture)
      • Classes and inheritance
      • Templates because of static typing
      • Some type inference with auto, but not everything can be inferred
  3. RECURRING CONCEPTS
    • Names (binding, scopes, environments)
    • Abstraction (data abstraction, procedural abstraction)
    • Typing (what entities can and cannot do)
    • Evaluation (everything about expressions)
    • Control (sequence, conditional, iteration, recursion, concurrency)
    • Architecture (functional or object oriented programming)
    • Concurrency (processes, threads, events, channels)

Things Learned in the Course

You want value from your education, right? So think about the major themes of that course. Think about what you learned. Think about things you can take from the course to be better in everything you do.

We learned a lot of really cool linguistic concepts that are widely applicable:

Now, let's organize all the knowledge into a general conceptual framework. (Note: not everything was covered in the course.)

[1] NAMES
      Names
      Binding
      Polymorphism vs. Aliasing
      Lifetime of bindings
        Entity outliving binding (usually ok)
        Binding outliving entity (uh-oh)
      Static, stack, and heap storage
      Scope: static and dynamic
      Binding: deep vs. shallow
      Shadowing declarations
      Memory leaks
      Dangling references
      Closures (do they cause memory leaks)
      Pointers to locals

[2] COMPUTATION
      Statements, Expressions, Declarations
      Operators
        Precedence
        Associativity
        Arity
        Fixity
      Evaluation Order
      Short-circuiting
      Side effects
      L-values and R-values
      Initialization and assignment
      Sequencing
      Selection (Conditional)
        If/elsif/else and switch
      Iteration - lots of different ways to do this!
        Logically controlled loops (usually while, do-while)
        Enumeration controlled loops (for-of, for-in, ...)
        Exiting from the middle of a loop
        Iterator objects (Python, Java, C++ have these)
      Recursion
        Base case vs. Recursive Step
        Beware of multi-way recursion: MEMOIZE!
        Tail recursion
      Non-determinacy
      Asynchronicity
        The idea of the single-threaded event queue
        Callbacks
        Promises
        Async/Await
      Concurrency
        Examples of concurrency
        Theoretical foundations
        Three architectures
          Distributed (multi-processing, message passing)
          Threads (multi-threaded, within processes, shared memory)
          Event-based (just one thread, repeatedly reads queue and services event)
        Three kinds of agents
          Actors (communicate via mailboxes)
          Goroutines (communicate via named channels)
          Coroutines (share a thread but yield to each other)
        Concurrency in Go
          Goroutines
          Channels
            Unbuffered (sync, waiting, blocking)
            Buffered (async, no-wait, no-blocking)

[3] TYPES
      Type systems
        Equivalence (nominal vs. structural) 
        Compatibility 
        Inference - how much inference can we do?
        Checking
          Strong vs. Weak
          Static vs. Dynamic
          Manifest vs. Implicit
        Inference
      Common types
        Scalar types
        Collections
        Arrays
        Records
        Strings
        Regular Expressions   [[ NOT COVERED - WILL GET TO IN CMSI 3802 ]]
        Pointers

[4] ABSTRACTION
      Functional Abstraction (subroutines, coroutines)
        Basic terminology
        Are parameters typed?
        Parameter association
          Named
          Positional
          Mixed
          Overloading
          Default parameters
          Rest parameters
        Function returns
        Argument passing
          Semantic
            in, out, in out
          Pragmatic
            By value
            By value-result
            By reference
            By name
            Aliasing
        Generic subroutines (for statically typed languages)
        Subroutines as values (higher order functions)
        Closures
          Comparison of closures to traditional objects
      Data Abstraction (Modules, classes, objects)
        Imports
        Exports
        Private to module vs. visible outside

[5] Metaprogramming

Suggested Practice Problems

Do reinforcement problems from the ple repo and from the course practice problems.

What To Expect

There will be 25 multiple choice, multi-select, and matching problems.

The final will be “open” all week, from Monday, December 12, through Friday, December 17 You may take the exam in whatever 2 hour period in this window is convenient for you. You are bound to the LMU Honor Code.

The exam will be on BrightSpace and have multi-select and multiple-choice problems—the kinds you are used to from previous exams.

A list of the main areas of concern for each of the 25 problems will appear on Slack, so stand by for those!