
This book shows how continuation-passing style is used as an intermediate representation to perform optimizations and program transformations. Continuations can be used to compile most programming languages. The method is illustrated in a compiler for the programming language Standard ML. Prior knowledge of ML, however, is not necessary, as the author carefully explains each concept as it arises. This is the first book to show how concepts from the theory of programming languages can be applied to the production of practical optimizing compilers for modern languages like ML. All the details of compiling are covered, including the interface to a runtime system and garbage collector.
The Tiger book (with C, Standard ML, and Java variants)
https://www.cs.princeton.edu/~appel/modern/
Compiler Design in C (freely available nowadays, beware this is between K&R C and C89)
lcc, A Retargetable Compiler for ANSI C
Or if one wants to go with more clever stuff,
Compiling with Continuations
Lisp in Small Pieces
I bought it because it demonstrated how to cps-transform code, which was my goal. I think it delivered.
For a "broader perspective", see the follow-up papers:
Compiling with Continuations, Continued (2007) (Cited by 154)” “The Essence of Compiling with Continuations (1993) (Cited by 806)” “Compiling with continuations, or without? whatever. (2019) (Cited by 34)”
(...which TFA characterised as "parody")FWIW, after I implemented CPS this way, I eventually switched to ANF for typing reasons. I'm a bit of a beginner at type inference and could not assign a meaningful type to the extra term ("continuation") that CPS produces (and which ANF does not).
[1] https://www.microsoft.com/en-us/research/wp-content/uploads/...
Ultimately I read the classic book "Compiling with Continuations", and it basically cleared up all my confusions.
All of this is to say, don't discount books and courses. They will almost always be more in depth and correct than what you will find written up on a website.