
Compiling with Continuations
by Andrew W. Appel · first published 1992
47mentions
19recommended by
35HN commenters
2009–2026first – last mentioned
54% recommend43% neutral3% critical
Why HN recommends it
In-depth treatment of continuation-passing style as a compiler intermediate form, with the CPS transformation and optimization explained concretely in ML. Suits people building functional-language compilers.
Summarised by Claude from recommending comments
Affiliate links. As an Amazon Associate I earn from qualifying purchases.








…reader in mind. The intro book people should look at is (as mentioned elsewhere), should be the intro to compilers in ml book by appel, and for advanced stuff folks should look at stuff like appel's compiling with continuations, the munchnick (spelling?) book, and one or two others. I think the point is that 1) most exposure to the dragon book for most folks predates the 2nd edition, and in your experience, most of the learning…
on “Learning to write a compiler” ↗…writeup on their use of the Cheney Trampoline. As is always the case in such discussions, I'll mention these three fine books for Scheme implementers: * Lisp in small pieces, by Christian Queinnec * Compiling with continuations, by Andrew Appel * Anatomy of Lisp, by John Allen
on “How Chicken Scheme compiles to C” ↗I recommend Lisp In Small Pieces (LISP) by Christian Queinnec and Compiling with Continuations by Andrew Appel if you're interested in writing a functional compiler. Also: http://matt.might.net/articles/cps-conversion/ http://lucacardelli.name/Papers/BasicTypechecking.pdf http://library.readscheme.org/page1.html…
on “Write You a Haskell: Building a modern functional compiler from first principles” ↗Yes. Check out the book "Compiling with Continuations" by Andrew Appel. Not only can a compiler "convert direct style to CPS under the hood," it's one of the more efficient and effective ways to implement a compiler. At a high level, CPS provides an intermediate…
on “Can continuation passing style code perform well?” ↗…Techniques in {ML,C}_ books. The ML one is better, IMHO. Those cover other methods (LL, LALR, SLR, etc.) in greater detail, and I'd also recommend either for learning compilers in a heartbeat. (Appel's _Compiling with Continuations_ is also excellent, but doesn't cover parsing.) Following that, Dick Grune's _Parsing Techniques: A Practical Guide_ (http://www.few.vu.nl/~dick/PTAPG.html) is a good reference...and thorough. If you're…
on “A quick intro to writing a parser with Treetop” ↗…http://caml.inria.fr/pub/docs/oreilly-book/html/index.html). It covers a slightly older version of the language, but that mostly impacts libraries. Andrew Appel's _Modern Compiler Implementation in ML_ and _Compiling with Continuations_ are both great compiler books, which happen to use SML for the code. Joshua Smith's _Practical OCaml_ is bad. Really bad. I was shocked. Avoid. Chris Okasaki's _Purely Functional Data Structures_ is…
on “The 3 Programming Languages you need to Know” ↗…Abelson and diSessa, Turtle Geometry Abelson and Sussman, Structure and Interpretation of Computer Programs Aho and Weinberger and Kernighan, The AWK Programming Language Andrew Appel, Compiling With Continuations Jon Bentley, More Programming Pearls Jon Bentley, Programming Pearls Leo Brodie, Thinking FORTH W. H. Burge, Recursive Programming Techniques Carriero and Gelernter, How to Write Parallel…
on “Which programming book you just couldn’t stop reading from start to end?” ↗A lot has changed. If you're looking at other strongly-typed functional language, particularly if you don't have to handle laziness, Compiling with Continuations is a fantastic book (http://www.amazon.com/Compiling-Continuations-Andrew-W-Appel... ). There is still a lot that has changed since then. In particular: 1) Control-flow analysis has become much more…
on “The Implementation of Functional Programming Languages” ↗…particular order) are: * Engineering a Compiler: https://www.amazon.com/Engineering-Compiler-Second-Keith-Coo... * Modern Compiler Implementation in ML: https://www.cs.princeton.edu/~appel/modern/ml/ * Compiling with Continuations: https://www.amazon.com/Compiling-Continuations-Andrew-W-Appe...
on “Programming books you might want to consider reading” ↗Lovely article! Following up on the section about threaded code, Andrew W. Appel's book _Compiling With Continuations_ really blew my mind and changed how I think about the interconnections between compilation, optimization, and language design. There are many ways into that deep set of ideas; I recommend the Appel book…
on “When pigs fly: optimising bytecode interpreters” ↗For good descriptions of using CPS as an intermediate representation in a compiler, check out Appel's _Compiling with Continuations_, Guy L. Steele's "Rabbit" thesis, Krantz's "Orbit" thesis, and chapter 12 of the first edition of _Essentials of Programming Languages_ (they cut it from later editions, unfortunately). Appel uses ML,…
on “By example: Continuation-passing style in JavaScript ” ↗Its more geared towards ML but I found Appel's Compiling with Continuations very interesting.
on “Join the Compiler Creation Club” ↗Appel has a book on compiling with CPS Compiling with Continuations. It’s implemented in SML so the types are front and center. Might be of use!
on “Bril: An Intermediate Language for Teaching Compilers” ↗I've never actually looked at that compiler, so can't comment on it, but have you read Appel's "Compiling with Continuations"? It motivates and explains the process very clearly. Add ANF into the mix and it's a very straightforward, well-defined system - much more so than SSA.
on “Why SSA?” ↗…lambda calculus, most importantly continuation passing style. Most semantics text introduce lambda calculus and its three rules, but none go in depth into this like the tall green book by Andrew Appel, "Compiling with Continuations", a good chunk of which can be read in Appel's other papers. Appel's work is MLish in nature, but don't let that stop you; most optimizing Lisp compilers are MLish down underneath anyway. CMUCL does very…
on “ACM 20 Most Influential Papers on Programming Languages [tarball]” ↗