Skip to main content

Welcome to this course

This is an equal opportunity course that offers you a supportive and inclusive space to learn. Everyone, no matter their age, gender, race, or nationality, can be successful in this course. People like you are joining from all over the world and we value this diversity. We hope you enjoy learning about topics that are important to you.

About This Course

This self-paced course will discuss the major ideas used today in the implementation of programming language compilers, including lexical analysis, parsing, syntax-directed translation, abstract syntax trees, types and type checking, intermediate languages, dataflow analysis, program optimization, code generation, and runtime systems. As a result, you will learn how a program written in a high-level language designed for humans is systematically translated into a program written in low-level assembly more suited to machines. Along the way we will also touch on how programming languages are designed, programming language semantics, and why there are so many different kinds of programming languages.

The course lectures will be presented in short videos. To help you master the material, there will be in-lecture questions to answer, quizzes, and two exams: a midterm and a final. There will also be homework in the form of exercises that ask you to show a sequence of logical steps needed to derive a specific result, such as the sequence of steps a type checker would perform to type check a piece of code, or the sequence of steps a parser would perform to parse an input string. This checking technology is the result of ongoing research at Stanford into developing innovative tools for education, and we're excited to be the first course ever to make it available to students.

An optional course project is to write a complete compiler for COOL, the Classroom Object Oriented Language. COOL has the essential features of a realistic programming language, but is small and simple enough that it can be implemented in a few thousand lines of code. Students who choose to do the project can implement it in either C++ or Java.

I hope you enjoy the course!

Why Study Compilers?

Everything that computers do is the result of some program, and all of the millions of programs in the world are written in one of the many thousands of programming languages that have been developed over the last 60 years. Designing and implementing a programming language turns out to be difficult; some of the best minds in computer science have thought about the problems involved and contributed beautiful and deep results. Learning something about compilers will show you the interplay of theory and practice in computer science, especially how powerful general ideas combined with engineering insight can lead to practical solutions to very hard problems. Knowing how a compiler works will also make you a better programmer and increase your ability to learn new programming languages quickly.


No prerequisites are needed for this course.

Course Staff

Course Staff Image #1

Alex Aiken

Alex Aiken is a Professor of Computer Science at Stanford University, where he holds the Alcatel-Lucent Chair. Alex received his Bachelors degree in Computer Science and Music from Bowling Green State University in 1983 and his Ph.D. from Cornell in 1988. Alex was a Research Staff Member at the IBM Almaden Research Center (1988-1993) and a Professor in the EECS department at UC Berkeley (1993-2003) before joining Stanford in 2003. He is an ACM Fellow, a recipient of Phi Beta Kappa's Teaching Award, a former National Young Investigator, and has served on a number of corporate advisory boards. Alex's research interests cover a range of topics in programming languages, compilers, and software engineering.

Frequently Asked Questions

Do I need to buy a textbook?

No, no textbook is required for the class. However, you may find a textbook useful as a reference or to learn more details of some of the ideas discussed in the course. There are a number of good textbooks on compilers; here are three in particular:

  1. Compilers: Principles, Techniques, and Tools (Second Edition)
    Alfred Aho, Monica Lam, Ravi Sethi, and Jeffrey Ullman.

  2. Modern Compiler Implementation in Java (Second Edition)
    Andrew Appel and Jens Palsberg.
    Cambridge University Press

  3. Engineering a Compiler
    Keith Cooper and Linda Torczon.
    Morgan Kaufman

Will I get a Statement of Accomplishment after completing this class?

Yes. Students who successfully complete the class will receive a statement of accomplishment signed by the instructor.

How is the class structured?

Each week there will be a number of videos to watch, most of which will include an in-video quiz question to answer. Most weeks there will also be homeworks (done on-line) and a quiz. There will be also be a midterm and a final exam.

How do I ask questions?

There will be an online discussion forum in which students can ask questions and receive answers. As this course is self-paced, the forum will be largely unmoderated. Answers will come from fellow participants, as a result.

How much does the course cost?

The course is free and there is no charge for registering on the site.

How much time will I need to apply to this course each week?

The estimated effort per week will vary per student, but basically, you should expect to spend:

  • * 3 hours per week in this course if you are not planning to do the programming assignments.
  • * 6-10 hours per week for experienced programmers.

Your mileage will vary, depending on how well you already know the programming language, how long it takes to learn to use the tools and libraries, and how experienced you are at debugging.

Icons CCBY: Noun Project Cara Foster, Adrien Coquet