Coupons

15312 Foundations Of Programming Languages

The course builds up from simple systems to complex ones.

Before writing code, you define the "grammar" of a language using BNF (Backus-Naur Form). You will learn to think in terms of Abstract Syntax Trees (ASTs) rather than text strings.

15-312 is famous for using Standard ML (SML) as its implementation language. Why SML?

Furthermore, advanced sections use Twelf (a logical framework) to encode programming language definitions as logic programs. In Twelf, you declare rules, and the system checks if your type safety proof is valid. It’s like a proof assistant for language designers.

15-312: Foundations of Programming Languages is a course that stays with a programmer long after they have forgotten the syntax of SML. It is an initiation into the "deep magic" of computation.

It produces a breed of programmer who does not fear the compiler, who understands the logical structure of the systems they build, and who can learn a new language in an afternoon because they understand the universal components—syntax, statics, and dynamics—that constitute all languages. It is a rigorous reminder that beneath the chaotic surface of modern software engineering lies a beautiful, immutable foundation of logic.

In the quiet corridors of Gates Hillman, the legend of " 15-312: Foundations of Programming Languages

" began not with a line of code, but with a question: What is a program, truly?

The students of Carnegie Mellon University knew 15-312 wasn't just a class; it was a rite of passage into the abstract. While others wrestled with memory leaks in C, the "312" crowd sat in the TR 12:30 PM lecture contemplating the cosmic elegance of Type Theory and the "Progress and Preservation" of the universe itself. The Protagonist: The Compiler's Apprentice

Meet Alex, a junior who thought they knew how to code until they met the Abstract Syntax Tree (AST). Alex's journey started in the "Initial State"—a messy world of untyped variables and runtime crashes.

Their mission? To reach the "Final State" of total type safety. The Antagonist: The Segmentation Fault

In the early weeks, Alex faced the dread of the Dynamics. The rules of transition were strict. One misplaced inference rule, and the entire proof tree would collapse like a house of cards. The Segment Fault wasn't just a bug; it was a philosophical failure—a violation of the safety theorems that Professor Harper (the legendary architect of the course) guarded with ironclad logic. The Climax: The Great Induction

The mid-semester project arrived: implementing a language from scratch. Alex labored over SML (Standard ML), a language that felt like writing poetry with a very angry editor.

The Struggle: Every time Alex tried to run their code, the type checker screamed.

The Epiphany: It happened at 3:00 AM in a cluster. Alex realized that types weren't handcuffs—they were the blueprint. By proving the lemmas, Alex wasn't just fixing bugs; they were ensuring that the program could never fail in the first place. The Resolution: Preservation 15312 foundations of programming languages

Alex emerged from the final exam, exhausted but enlightened. They no longer saw code as a sequence of commands, but as a mathematical proof. As Alex walked toward the The Originals A Capella rehearsal, they realized that 15-312 had changed them.

The world was no longer a chaotic script; it was a well-typed system, where every action had a rule, and every state followed a logic that—if respected—guaranteed a perfect, crash-free existence.

Originally developed at Carnegie Mellon University, this course has become a gold standard for understanding how programming languages actually work—not just how to type syntax, but the mathematical soul of computation itself. What is 15-312 About?

At its core, 15-312 is about the mechanics of meaning. When you write x = x + 1, why does the computer know what to do?

The course focuses on the study of programming language phenomena using the tools of Type Theory and Operational Semantics. Instead of looking at languages like Java or Python as monolithic tools, you learn to see them as a collection of "features" (functions, recursion, exceptions, parallelism) that can be formally defined and proven correct. The Pillars of the Course 1. Abstract Syntax

The journey begins by moving away from "concrete syntax" (the curly braces and semicolons) and toward Abstract Syntax Trees (ASTs). You learn that a program is a structured mathematical object, not just a string of characters. 2. Statics: Type Systems

The "Statics" of a language define what it means for a program to be "well-formed" before it ever runs. You explore:

Type Safety: The famous slogan "Well-typed programs do not go wrong."

Type Inference: How a compiler can figure out what you mean without you telling it.

Polymorphism: Writing code that works across multiple types (generics). 3. Dynamics: Execution Models

The "Dynamics" describe how a program steps from one state to the next. Using Structural Operational Semantics (SOS), you write rules that dictate exactly how an expression evaluates. This is where you learn about:

Eager vs. Lazy Evaluation: When exactly does an argument get computed?

Continuations: How to represent the "rest of the program" as a first-class object.

Memory Management: The formal logic behind garbage collection and resource allocation. 4. The Safety Theorem The course builds up from simple systems to complex ones

The climax of the course is proving Preservation and Progress. Together, these two properties guarantee that if a program passes the type checker, it will either finish with a result or keep making progress—it will never crash or enter an undefined state. Why Study It?

If you plan on being a software engineer, you might wonder why you need this level of abstraction. The benefits are long-term:

Master New Languages Faster: Once you understand the underlying types (sums, products, functions), every new language is just a different combination of the same fundamental building blocks.

Write Correct Code: You start thinking like a type checker. You begin to catch "impossible" bugs before you even hit compile because you've designed your data structures to be mathematically sound.

Compiler Design: If you ever want to build your own DSL (Domain Specific Language) or contribute to a major compiler like LLVM or Rust, these foundations are non-negotiable. Recommended Resources

To master the material covered in 15-312, the primary text is almost always "Practical Foundations for Programming Languages" (PFPL) by Robert Harper. It is a dense, rigorous, but incredibly rewarding guide to the field.

15-312 isn't just a class; it’s a shift in perspective. It turns programming from an art of "poking the machine until it works" into a rigorous discipline of logic and proof.

15-312: Foundations of Programming Languages is a rigorous computer science course at Carnegie Mellon University (CMU) that explores the mathematical and structural principles of programming language design. It shifts the focus from simply using languages to understanding how they are defined, implemented, and proven correct through formal methods. Course Overview

Primary Objective: To examine the fundamental structure of programming languages from a mathematical perspective.

Key Philosophy: The course treats a programming language as a mathematical object rather than an ad-hoc collection of features.

Primary Textbook: Practical Foundations for Programming Languages (Second Edition) by Robert Harper. Core Topics Covered

The curriculum uses a single mathematical framework to describe various language concepts:

Mathematical Foundations: Inductive definitions, substitution, and rule induction.

Description Techniques: Abstract syntax, typing rules (statics), and abstract machines (dynamics). That’s it

Language Features: Functions, recursion, polymorphism, continuations, exceptions, mutable storage, and monads.

Safety & Proofs: Learning to prove that a language is "safe" (meaning it behaves predictably according to its rules) or finding counterexamples to safety. Course Structure & Grading

While specific distributions may vary by semester, a typical breakdown includes:

Assignments (45%–50%): A mix of programming assignments (often every two weeks) and written assignments.

Examinations (40%–50%): Usually includes a midterm (approx. 20%) and a comprehensive final exam (approx. 25%–30%).

Participation (5%): Based on recitation attendance and class contributions. Practical Details

Prerequisites: Typically requires proficiency in Standard ML (SML) and experience with writing formal proofs. Taking 15-212 (Principles of Programming) is a standard prerequisite.

Programming Language Used: Most implementation work (interpreters and language dynamics) is done in Standard ML (SML).

Workload: Expected to be significant, as students must implement interpreters derived directly from formal definitions. 15-312 Foundations of Programming Languages

If you strip a programming language down to its bare essence—no numbers, no loops, no assignment—you get the lambda calculus, invented by Alonzo Church in the 1930s.

It has only three things:

That’s it. And yet, the lambda calculus is Turing-complete—it can compute anything computable.

In 15312, students learn to encode numbers (Church numerals), booleans, pairs, and even recursion (using the Y combinator) from this tiny kernel.

The lambda calculus is the hydrogen atom of programming languages: simple, elegant, and the foundation of functional programming. Every time you write a closure in JavaScript or a lambda in Python, you are touching 1930s logic.


Primary Resource: Practical Foundations for Programming Languages (PFPL) by Robert Harper.