Computer ScienceProgramming Languages: Application and Interpretation
Not rated yetRate this bookProgramming Languages: Application and Interpretation explains language design by building and examining small interpreters. Shriram Krishnamurthi’s linked PDF is the second edition dated 14 April 2017, despite its location in a course directory containing 2012. Seventeen chapters develop parsing, interpretation, desugaring, functions, environments, state, recursion, objects, memory, macros, control, types, contracts, and evaluation strategies. This guide follows that version rather than importing a different edition’s organization. The central method is to make language behavior explicit, test competing designs, and connect an implementation choice with its observable semantic consequences.
Read on the publisher’s website. Opens in a new tab.
FreeAbout this book
Overview
Programming Languages: Application and Interpretation explains language design by building and examining small interpreters. Shriram Krishnamurthi’s linked PDF is the second edition dated 14 April 2017, despite its location in a course directory containing 2012. Seventeen chapters develop parsing, interpretation, desugaring, functions, environments, state, recursion, objects, memory, macros, control, types, contracts, and evaluation strategies. This guide follows that version rather than importing a different edition’s organization. The central method is to make language behavior explicit, test competing designs, and connect an implementation choice with its observable semantic consequences.
How to study this book
Run or reconstruct the small programs and interpreters as you read. Before executing an example, predict its value, environment, store effects, or error and explain the prediction. Keep separate diagrams for syntax, environments, and mutable storage so that different roles do not collapse into one mental picture. When extending an interpreter, write tests that distinguish the new semantics from a plausible incorrect implementation. Compare alternatives using observable behavior rather than familiarity with one programming language. Treat the source’s language and tooling as edition-specific; the guide’s focus is the design reasoning expressed through them.
Chapter and section study guide
Chapter 1 — Introduction
The book approaches languages through construction, experimentation, and interpretation rather than a survey of syntax alone. Small implementations expose decisions that larger systems can hide. The opening chapter explains the teaching philosophy, structure, and language used in examples. A program’s behavior should be investigated through precise questions and tests. Distinguish learning a particular implementation language from understanding the language being implemented. The goal is to reason about alternatives and their consequences, including choices that differ from the reader’s familiar programming habits.
Study application: Write down one familiar language behavior and propose a tiny experiment that could reveal an alternative interpretation.
Chapter 2 — Parsing
Parsing turns an external representation into structured syntax suitable for interpretation. The chapter uses a lightweight approach to separate syntactic recognition from evaluation. Data definitions and types make the expected forms explicit, while malformed inputs require a deliberate response. A parser should not silently perform the evaluator’s job or accept every structure without checking. Distinguish the surface notation from the abstract syntax tree. This separation makes later language extensions easier to understand because a change in notation need not change the underlying semantic operation.
Study application: Construct abstract syntax trees for several expressions and identify which malformed inputs the parser should reject.
Chapter 3 — A First Look at Interpretation
An interpreter recursively assigns meaning to the forms represented in the syntax tree. Arithmetic examples reveal the relationship between data structure and evaluation structure. Extending the language requires corresponding decisions in representation and interpretation. The chapter encourages noticing assumptions that seem obvious only because the initial language is small. A correct example result is not enough; tests should cover each form and distinguish evaluation from parsing. Explain why a recursive call corresponds to a subexpression and what kind of result the interpreter promises to produce.
Study application: Trace an arithmetic expression through parsing and interpretation, marking the value returned at each recursive call.
Chapter 4 — A First Taste of Desugaring
Desugaring translates convenient surface forms into a smaller core language. Subtraction and unary negation illustrate how new notation can sometimes be expressed using existing operations. The translation must preserve intended behavior, not merely produce something that looks similar. This approach separates user-facing convenience from the complexity of the evaluator. The chapter introduces a recurring design question: which features deserve core semantics and which can be defined through translation? Test edge cases and order-sensitive behavior when deciding whether a transformation is valid.
Study application: Define a desugaring for one surface form and test that its translated expression behaves as intended in several contexts.
Chapter 5 — Adding Functions
Functions introduce names, parameters, bodies, application, and a need to explain how arguments affect an expression. The chapter develops data representations and substitution as an explicit semantic mechanism. A substitution must respect the intended meaning of identifiers rather than perform careless textual replacement. Function application raises questions about evaluating arguments and finding definitions. Small examples help distinguish the chosen design from plausible alternatives. State the assumptions and trace the operation carefully, because later environment-based implementations should preserve the intended behavior rather than accidentally introduce a new scope rule.
Study application: Trace a function application by substitution and identify which occurrences of a name should and should not be replaced.
Chapter 6 — From Substitution to Environments
Environments record deferred substitutions and connect identifiers with values. Replacing substitution with lookup can improve implementation structure, but an incorrect environment rule can change semantics. The chapter uses this risk to expose scope and distinguish lexical from dynamic behavior. An environment represents a context for interpreting an expression, not a global bag of every binding ever encountered. Tests involving nested calls and shadowing are especially useful. Compare the new interpreter against the substitution model to identify where implementation convenience has accidentally altered meaning.
Study application: Construct a scope-sensitive test and explain why one environment strategy agrees with substitution while another gives a different result.
Chapter 7 — Functions Anywhere
First-class functions can appear as values, be passed, returned, and created within other expressions. Closures preserve the environment needed to interpret a function body according to lexical scope. The chapter connects nested functions with data representation and the distinction between definition and application contexts. A function value is more than its code when free identifiers require bindings. Trace which variables are captured and which are supplied as arguments. Use examples with shadowing and returned functions to test whether the implementation retains the correct environment.
Study application: Trace a returned closure through two applications, marking captured bindings separately from each call’s parameter bindings.
Chapter 8 — Mutation
Mutation requires distinguishing a name’s binding from a location and the changing value stored there. Structures and variables raise related but different semantic questions. Environments and stores serve different purposes, and evaluation may now produce both a value and an updated state. Order matters when expressions have effects. The chapter examines design choices and parameter passing through their observable behavior. Avoid extending a purely functional interpreter by hiding state in an unexplained side effect. Make the flow of storage explicit so aliasing and updates can be reasoned about.
Study application: Draw environment and store diagrams for two references to one mutable object and explain the result of an update through either reference.
Chapter 9 — Recursion and Cycles
Recursive procedures and cyclic data require representations that can refer back to themselves. The chapter examines how such structures are established and what happens if a value is observed before initialization is complete. Different approaches use state or other techniques to support recursion. Distinguish a recursive definition from an infinite execution: termination depends on the computation, not merely the presence of self-reference. Trace the construction and later use of the relationship separately. Tests should expose premature access and incorrect sharing rather than only successful examples.
Study application: Explain how a recursive binding becomes available and design a test that reveals an invalid observation during its construction.
Chapter 10 — Objects
Objects can be understood through combinations of state, functions, dispatch, and choices about member access and inheritance. The chapter develops object behavior rather than assuming one familiar object-oriented language defines the concept. Different designs distribute responsibility differently among objects and methods. A method call can be analyzed through the underlying interpreter mechanisms already studied. Compare alternatives by the behavior they permit and the complexity they introduce. This approach makes abstraction and encapsulation concrete while exposing hidden assumptions about lookup, identity, and extension.
Study application: Implement or sketch a small object with methods and explain how dispatch and private state arise from underlying language mechanisms.
Chapter 11 — Memory Management
Memory management concerns when storage can be reclaimed without changing program behavior. Reachability, liveness approximations, manual reclamation, and automated collection introduce different responsibilities and risks. The chapter distinguishes correct recovery from merely reducing memory use. Reclaiming needed data is unsound, while retaining unreachable data wastes resources. Conservative and precise approaches differ in what they can identify. Connect a collector’s reasoning with the language’s representation of values and references. Test with sharing and cycles, where simple reference intuitions can be misleading.
Study application: Draw a heap with roots, shared objects, and a cycle, then identify which objects a reachability-based collector can safely reclaim.
Chapter 12 — Representation Decisions
Internal representations affect implementation, errors, abstraction, and sometimes observable meaning. A convenient host-language representation can accidentally import behavior that the designed language did not intend. The chapter asks readers to distinguish a representation change from a semantic change. State what clients are allowed to observe before claiming two implementations are equivalent. Error behavior is part of the design and should be deliberate. Comparing examples across representations develops a disciplined understanding of abstraction boundaries rather than confidence based only on a few matching outputs.
Study application: Compare two representations of a value and design a context that would reveal whether an unintended semantic difference has been introduced.
Chapter 13 — Desugaring as a Language Feature
Macros and syntax transformations make translation available as a language mechanism. The chapter develops transformers, guards, identifier capture, and implications for language implementation. A transformation must preserve binding structure and intended evaluation behavior, not just rearrange symbols. Hygiene questions arise when introduced identifiers interact with names in the surrounding program. Desugaring can support expressive surface constructs while retaining a smaller core, but it requires precise contracts and tests. Trace both syntax and binding to understand why a plausible macro may fail.
Study application: Create a macro-like transformation and test it in a context containing a potentially conflicting identifier.
Chapter 14 — Control Operations
Control operations make the remainder of a computation an explicit object of study. Web interactions, continuation-passing style, generators, continuations, stacks, and tail calls reveal alternatives to a simple call-and-return picture. The chapter connects implementation transformations with user-visible behavior. A continuation represents what remains to be done in a particular computational context. Distinguish saving a value from saving a future computation. Small traces are essential because control transfer can obscure the order in which operations and effects occur.
Study application: Transform a small computation into continuation-passing style and explain what each continuation represents.
Chapter 15 — Static Types
Type systems check selected program invariants before execution according to a specified discipline. The chapter develops typing as a formal approximation of behavior, not a guarantee that a program fulfills every intention. Rules must align with the language’s constructs and evaluation. A system may reject some programs that would run safely while aiming to exclude a defined class of failures. Distinguish syntax, type, and runtime errors. Explain what property the checker establishes and what remains outside its scope before judging the usefulness of the design.
Study application: Derive a typing judgment for a small program and state one important behavioral property that the type alone does not prove.
Chapter 16 — Dynamic Contracts
Contracts check specified expectations during execution and can express properties beyond a simple static type. The chapter examines how checks interact with values, functions, boundaries, and responsibility for violations. A check’s timing and placement affect what failure can be detected and how it is explained. Contracts do not remove the need to define the intended property precisely. Compare their role with static types rather than treating the approaches as interchangeable competitors. Tests should consider both valid uses and violations that reveal who failed to meet an obligation.
Study application: Specify a function contract and trace a violation across a boundary, explaining which obligation was broken.
Chapter 17 — Alternate Application Semantics
Evaluation strategies change when arguments are evaluated and how results or computations are shared. The chapter compares alternatives to the earlier application semantics and examines their observable consequences. Effects, divergence, repeated computation, and performance can distinguish strategies that appear equivalent on simple arithmetic. A language choice should be understood through examples and rules rather than labels alone. Connect the implementation mechanism with the promised behavior. The final chapter reinforces the book’s central method: identify a design choice, make it explicit, and test the consequences.
Study application: Construct examples involving an unused divergent argument and a repeated effect to distinguish alternative evaluation strategies.
Reflection and review
- Which implementation shortcut could accidentally change lexical scope or evaluation order?
- How can a test distinguish two semantic designs that agree on simple examples?
- What does a type, contract, or garbage collector guarantee, and what remains outside that guarantee?
Source and edition notes
Second edition, dated 14 April 2017 in the linked PDF; seventeen chapters, 207 PDF pages. The PDF itself dates the second edition to 14 April 2017; the older course-directory name is not used as the publication date. The original source-PDF title page is displayed as its cover.
Book summary
Overview
Programming Languages: Application and Interpretation explains language design by building and examining small interpreters. Shriram Krishnamurthi’s linked PDF is the second edition dated 14 April 2017, despite its location in a course directory containing 2012. Seventeen chapters develop parsing, interpretation, desugaring, functions, environments, state, recursion, objects, memory, macros, control, types, contracts, and evaluation strategies. This guide follows that version rather than importing a different edition’s organization. The central method is to make language behavior explicit, test competing designs, and connect an implementation choice with its observable semantic consequences.
How to study this book
Run or reconstruct the small programs and interpreters as you read. Before executing an example, predict its value, environment, store effects, or error and explain the prediction. Keep separate diagrams for syntax, environments, and mutable storage so that different roles do not collapse into one mental picture. When extending an interpreter, write tests that distinguish the new semantics from a plausible incorrect implementation. Compare alternatives using observable behavior rather than familiarity with one programming language. Treat the source’s language and tooling as edition-specific; the guide’s focus is the design reasoning expressed through them.
Chapter and section study guide
Chapter 1 — Introduction
The book approaches languages through construction, experimentation, and interpretation rather than a survey of syntax alone. Small implementations expose decisions that larger systems can hide. The opening chapter explains the teaching philosophy, structure, and language used in examples. A program’s behavior should be investigated through precise questions and tests. Distinguish learning a particular implementation language from understanding the language being implemented. The goal is to reason about alternatives and their consequences, including choices that differ from the reader’s familiar programming habits.
Study application: Write down one familiar language behavior and propose a tiny experiment that could reveal an alternative interpretation.
Chapter 2 — Parsing
Parsing turns an external representation into structured syntax suitable for interpretation. The chapter uses a lightweight approach to separate syntactic recognition from evaluation. Data definitions and types make the expected forms explicit, while malformed inputs require a deliberate response. A parser should not silently perform the evaluator’s job or accept every structure without checking. Distinguish the surface notation from the abstract syntax tree. This separation makes later language extensions easier to understand because a change in notation need not change the underlying semantic operation.
Study application: Construct abstract syntax trees for several expressions and identify which malformed inputs the parser should reject.
Chapter 3 — A First Look at Interpretation
An interpreter recursively assigns meaning to the forms represented in the syntax tree. Arithmetic examples reveal the relationship between data structure and evaluation structure. Extending the language requires corresponding decisions in representation and interpretation. The chapter encourages noticing assumptions that seem obvious only because the initial language is small. A correct example result is not enough; tests should cover each form and distinguish evaluation from parsing. Explain why a recursive call corresponds to a subexpression and what kind of result the interpreter promises to produce.
Study application: Trace an arithmetic expression through parsing and interpretation, marking the value returned at each recursive call.
Chapter 4 — A First Taste of Desugaring
Desugaring translates convenient surface forms into a smaller core language. Subtraction and unary negation illustrate how new notation can sometimes be expressed using existing operations. The translation must preserve intended behavior, not merely produce something that looks similar. This approach separates user-facing convenience from the complexity of the evaluator. The chapter introduces a recurring design question: which features deserve core semantics and which can be defined through translation? Test edge cases and order-sensitive behavior when deciding whether a transformation is valid.
Study application: Define a desugaring for one surface form and test that its translated expression behaves as intended in several contexts.
Chapter 5 — Adding Functions
Functions introduce names, parameters, bodies, application, and a need to explain how arguments affect an expression. The chapter develops data representations and substitution as an explicit semantic mechanism. A substitution must respect the intended meaning of identifiers rather than perform careless textual replacement. Function application raises questions about evaluating arguments and finding definitions. Small examples help distinguish the chosen design from plausible alternatives. State the assumptions and trace the operation carefully, because later environment-based implementations should preserve the intended behavior rather than accidentally introduce a new scope rule.
Study application: Trace a function application by substitution and identify which occurrences of a name should and should not be replaced.
Chapter 6 — From Substitution to Environments
Environments record deferred substitutions and connect identifiers with values. Replacing substitution with lookup can improve implementation structure, but an incorrect environment rule can change semantics. The chapter uses this risk to expose scope and distinguish lexical from dynamic behavior. An environment represents a context for interpreting an expression, not a global bag of every binding ever encountered. Tests involving nested calls and shadowing are especially useful. Compare the new interpreter against the substitution model to identify where implementation convenience has accidentally altered meaning.
Study application: Construct a scope-sensitive test and explain why one environment strategy agrees with substitution while another gives a different result.
Chapter 7 — Functions Anywhere
First-class functions can appear as values, be passed, returned, and created within other expressions. Closures preserve the environment needed to interpret a function body according to lexical scope. The chapter connects nested functions with data representation and the distinction between definition and application contexts. A function value is more than its code when free identifiers require bindings. Trace which variables are captured and which are supplied as arguments. Use examples with shadowing and returned functions to test whether the implementation retains the correct environment.
Study application: Trace a returned closure through two applications, marking captured bindings separately from each call’s parameter bindings.
Chapter 8 — Mutation
Mutation requires distinguishing a name’s binding from a location and the changing value stored there. Structures and variables raise related but different semantic questions. Environments and stores serve different purposes, and evaluation may now produce both a value and an updated state. Order matters when expressions have effects. The chapter examines design choices and parameter passing through their observable behavior. Avoid extending a purely functional interpreter by hiding state in an unexplained side effect. Make the flow of storage explicit so aliasing and updates can be reasoned about.
Study application: Draw environment and store diagrams for two references to one mutable object and explain the result of an update through either reference.
Chapter 9 — Recursion and Cycles
Recursive procedures and cyclic data require representations that can refer back to themselves. The chapter examines how such structures are established and what happens if a value is observed before initialization is complete. Different approaches use state or other techniques to support recursion. Distinguish a recursive definition from an infinite execution: termination depends on the computation, not merely the presence of self-reference. Trace the construction and later use of the relationship separately. Tests should expose premature access and incorrect sharing rather than only successful examples.
Study application: Explain how a recursive binding becomes available and design a test that reveals an invalid observation during its construction.
Chapter 10 — Objects
Objects can be understood through combinations of state, functions, dispatch, and choices about member access and inheritance. The chapter develops object behavior rather than assuming one familiar object-oriented language defines the concept. Different designs distribute responsibility differently among objects and methods. A method call can be analyzed through the underlying interpreter mechanisms already studied. Compare alternatives by the behavior they permit and the complexity they introduce. This approach makes abstraction and encapsulation concrete while exposing hidden assumptions about lookup, identity, and extension.
Study application: Implement or sketch a small object with methods and explain how dispatch and private state arise from underlying language mechanisms.
Chapter 11 — Memory Management
Memory management concerns when storage can be reclaimed without changing program behavior. Reachability, liveness approximations, manual reclamation, and automated collection introduce different responsibilities and risks. The chapter distinguishes correct recovery from merely reducing memory use. Reclaiming needed data is unsound, while retaining unreachable data wastes resources. Conservative and precise approaches differ in what they can identify. Connect a collector’s reasoning with the language’s representation of values and references. Test with sharing and cycles, where simple reference intuitions can be misleading.
Study application: Draw a heap with roots, shared objects, and a cycle, then identify which objects a reachability-based collector can safely reclaim.
Chapter 12 — Representation Decisions
Internal representations affect implementation, errors, abstraction, and sometimes observable meaning. A convenient host-language representation can accidentally import behavior that the designed language did not intend. The chapter asks readers to distinguish a representation change from a semantic change. State what clients are allowed to observe before claiming two implementations are equivalent. Error behavior is part of the design and should be deliberate. Comparing examples across representations develops a disciplined understanding of abstraction boundaries rather than confidence based only on a few matching outputs.
Study application: Compare two representations of a value and design a context that would reveal whether an unintended semantic difference has been introduced.
Chapter 13 — Desugaring as a Language Feature
Macros and syntax transformations make translation available as a language mechanism. The chapter develops transformers, guards, identifier capture, and implications for language implementation. A transformation must preserve binding structure and intended evaluation behavior, not just rearrange symbols. Hygiene questions arise when introduced identifiers interact with names in the surrounding program. Desugaring can support expressive surface constructs while retaining a smaller core, but it requires precise contracts and tests. Trace both syntax and binding to understand why a plausible macro may fail.
Study application: Create a macro-like transformation and test it in a context containing a potentially conflicting identifier.
Chapter 14 — Control Operations
Control operations make the remainder of a computation an explicit object of study. Web interactions, continuation-passing style, generators, continuations, stacks, and tail calls reveal alternatives to a simple call-and-return picture. The chapter connects implementation transformations with user-visible behavior. A continuation represents what remains to be done in a particular computational context. Distinguish saving a value from saving a future computation. Small traces are essential because control transfer can obscure the order in which operations and effects occur.
Study application: Transform a small computation into continuation-passing style and explain what each continuation represents.
Chapter 15 — Static Types
Type systems check selected program invariants before execution according to a specified discipline. The chapter develops typing as a formal approximation of behavior, not a guarantee that a program fulfills every intention. Rules must align with the language’s constructs and evaluation. A system may reject some programs that would run safely while aiming to exclude a defined class of failures. Distinguish syntax, type, and runtime errors. Explain what property the checker establishes and what remains outside its scope before judging the usefulness of the design.
Study application: Derive a typing judgment for a small program and state one important behavioral property that the type alone does not prove.
Chapter 16 — Dynamic Contracts
Contracts check specified expectations during execution and can express properties beyond a simple static type. The chapter examines how checks interact with values, functions, boundaries, and responsibility for violations. A check’s timing and placement affect what failure can be detected and how it is explained. Contracts do not remove the need to define the intended property precisely. Compare their role with static types rather than treating the approaches as interchangeable competitors. Tests should consider both valid uses and violations that reveal who failed to meet an obligation.
Study application: Specify a function contract and trace a violation across a boundary, explaining which obligation was broken.
Chapter 17 — Alternate Application Semantics
Evaluation strategies change when arguments are evaluated and how results or computations are shared. The chapter compares alternatives to the earlier application semantics and examines their observable consequences. Effects, divergence, repeated computation, and performance can distinguish strategies that appear equivalent on simple arithmetic. A language choice should be understood through examples and rules rather than labels alone. Connect the implementation mechanism with the promised behavior. The final chapter reinforces the book’s central method: identify a design choice, make it explicit, and test the consequences.
Study application: Construct examples involving an unused divergent argument and a repeated effect to distinguish alternative evaluation strategies.
Reflection and review
- Which implementation shortcut could accidentally change lexical scope or evaluation order?
- How can a test distinguish two semantic designs that agree on simple examples?
- What does a type, contract, or garbage collector guarantee, and what remains outside that guarantee?
Source and edition notes
Second edition, dated 14 April 2017 in the linked PDF; seventeen chapters, 207 PDF pages. The PDF itself dates the second edition to 14 April 2017; the older course-directory name is not used as the publication date. The original source-PDF title page is displayed as its cover.
This page provides book information and study material. Full-text access is provided by the original publisher or authorised source; a listing does not grant permission to republish the book.
Read our Library Access & Copyright policyExplore the contents
Check the chapters covered in this edition.
Visit the official source
See reading, preview or purchase options.
Save for later
Keep this textbook in your saved collection.
Reader ratings & reviews
Share your thoughts
Your review helps other students choose the right resources.









