Skip to content

CS242 Programming Languages

Descriptions

  • Offered by: Stanford
  • Prerequisites: basic knowledge about programming language theory and computer system
  • Programming Languages: OCaml, Rust
  • Difficulty: 🌟🌟🌟🌟
  • Class Hour: 60 hours

CS242 is a course about programming languages (PL), but it is not a pure theoretical course in the traditional sense. This course first introduces classic PL theories such as Lambda calculus and type system, then uses the ideas and actual programming languages of system programming to motivate students to understand these theories, and shows how they help developers avoid various errors in actual programming.

The instructor Will Crichton also wrote his course design ideas into a paper From Theory to Systems: A Grounded Approach to Programming Language Education, which elaborates this teaching route from theory to systems.

We help readers understand the specific content of this course by simply introducing each assignment:

  • Formalization and proof of JSON
  • Classic Lambda calculus in PL
  • Introduction to functional programming using OCaml
  • Use OCaml to implement a type checker and interpreter for a functional language, which is also a classic assignment in PL
  • Theory and practice of WebAssembly
  • Linear Type and Rust's ownership mechanism
  • Rust's asynchronous programming basics
  • Design state machines and implement session-typed TCP libraries using Rust's type system
  • The final assignment has four options:
    1. Theorem proving in Lean
    2. Read-Log-Update in Rust
    3. Verified filesystems in F-Star
    4. Deep learning framework in OCaml from a PL perspective

These assignments cover a wide range of knowledge, from the classic PL theory and practice to the impact of programming languages such as Rust on programming and system design, and finally the distinctive projects. Almost all programming assignments have detailed local tests, especially the deep learning framework in the final project has more than 200 tests, which is suitable for self-study.

The first few assignments are more about PL theory, and the later assignments are more about system programming. If you think that the course content and assignments in the first few times are too theoretical, you can focus on the assignment of implementing the interpreter using OCaml, which can not only help you have a deeper understanding of the previous theory, but also let you practice the type checking and interpretation of a functional language.

The later assignments tend to use theory to guide system programming and design, especially Rust and its unique ownership mechanism and type system. Although we often have to fight with the compiler, this also just shows the significance of type systems and theories for programming and design.

I personally feel that the assignments are difficult, but the gains are great. When the programming practice in the later assignments intersects with the theoretical knowledge learned before, there will be a pleasant feeling of sudden enlightenment. If you encounter difficulties in completing the assignments, this is normal. Please calm down and think carefully, or read the assignment guide again.

Course Resources