Course Syllabus

Course Description and Learning Objectives

This course introduces students to the design and implementation of compilers for programming languages. Specifically, students will learn how to systematically translate modern, high-level, programming languages into efficient, executable machine code.

The course introduces a number of important concepts, such as parsing and program analysis that are useful in many other contexts beyond compilers, such as software engineering and security. Perhaps the most useful outcome of the course is that students will deeply understand the capabilities and limitations of modern compilers, and how they can be used most effectively. This knowledge is important for aspiring language designers and implementors, but also for debugging and optimizing just about any application.

This course is extremely programming intensive, as most of the understanding comes from constructing (small) compilers.

Recommended Prerequisites

Computer Science 51 or Computer Science 61. (Ideally, both CS51 and CS61.) Students should be comfortable programming in OCaml. Note that this is a programming-intensive course: some weeks may require tens of hours of programming.

You can try the self assessment to help figure out whether you are adequately prepared. Also, the first homework assignment (released in the first week) is designed to help get you up to speed in programming in OCaml.

Time and Place

Lectures are Mondays and Wednesdays, 12:45-2:00pm, in SEC 1.413

Course staff

  • Instructor: Stephen Chong
  • Teaching Fellows:
    • Cameron Wong
    • Raffi Sanna

See the Office Hours page for office hours. 

All questions and issues related to assignments, course content, etc., should be posted on the course discussion website (accessed via the "Ed Discussion" link in the Canvas menu; make sure you are logged in and enrolled in the course to see the link). Questions related to grades, special consideration, etc. can be sent directly to Prof. Chong. If you want to contact the course staff for something else, please use cs1530-staff@seas.harvard.edu, which goes to all CS1530 staff. In general, sending email to individual course staff will delay a response. Note that course staff may take up to 48 hours to respond to posts, questions, etc. That is, don't expect a quick answer close to a deadline!

Grading/Assessment

Your grade will be determined by a weighted average of your scores on projects, the final exam, and class participation. The weightings below are tentative and subject to change.

0% Self-assessment

A self-assessment test is available to help you evaluate whether you have the pre-requisite background for the course.

10% Class Participation Includes participation in office hours, section, study groups, and/or online discussions, and attempting extra-credit portions of the project. That is, engagement in the course and the course material beyond watching lectures and completing projects.
70% Projects There will be ~6 projects in this course, mostly involve implementing parts of a compiler. Implementation will be in OCaml, and we assume that students are comfortable with programming in OCaml. The projects will not be weighted equally, as the projects vary in difficulty. In particular, the first homework will have about half the weight of other project.
20% Final exam 3-hour final exam. Thursday December 18, 2pm, in Northwest B101

Descriptions of grades can be found in the Student Handbook. Here I describe what grades mean in this course.

  • An A is earned by work of “extraordinary distinction", whose "excellent quality" indicates "a full mastery of the subject". In CS 1530, this means:
    • Full participation in all aspects of the course (lectures, office hours, study groups, online forum, etc.)
    • Active engagement beyond requirements, as evidenced by, for example, asking insightful questions, contributing answers, and exploring optional/extra-credit challenges.
    • Deep and precise understanding of the entire compilation pipeline, with the ability to compare and justify design choices among algorithms and techniques.
    • Strong implementation skills: correct, efficient, well-designed, well-documented, and well-tested compiler code.
    • Ability to read, explain, and appropriately extend or modify unfamiliar code.
  • An A– is earned by work whose "excellent quality" indicates a “full mastery of the subject.” In CS 1530, this means:
    • Consistent participation in the course (lectures, office hours, study groups, online forum, etc.)
    • Active engagement beyond requirements, as evidenced by, for example, asking insightful questions, contributing answers, and exploring optional/extra-credit challenges.
    • Solid understanding of the entire compilation pipeline, with the ability to explain how and why key components and algorithms work. 
    • Solid implementation skills: mostly correct, reasonably efficient, reasonably designed, documented, and tested compiler code.
    • Ability to read, explain, and appropriately extend or modify unfamiliar code.
  • A B+, B, or B– is earned by work that indicates a “good comprehension of the course material, a good command of the skills needed to work with the course material, and the student’s full engagement with the course requirements and activities." In CS 1530, this means:
    • Regular attendance and timely completion of all homeworks.
    • Understanding of the entire compilation pipeline, but may have gaps in understanding of some components or algorithms. 
    • Ability to implement compiler components, although code may lack correctness on a significant number of inputs, may be inefficient, may lack documentation, and/or may exhibit poor design.
    • Ability to follow existing code, modifications and extensions may be correct but limited in scope or depth.
  • A C+, C, or C– is earned by work that indicates an “adequate and satisfactory comprehension of the course material and the skills needed to work with the course material." In CS 1530, this means:
    • Inconsistent participation or limited engagement with course activities; completion of nearly all homeworks. 
    • Basic understanding of the entire compilation pipeline, but may have significant gaps in understanding of some components or algorithms. 
    • Ability to implement simpler parts of the compiler, but some portions might be incomplete, code may lack correctness on a significant number of inputs, may be inefficient, may lack documentation, and/or may exhibit poor design.

Course Materials

The textbook "Modern Compiler Implementation in ML" by Andrew W. Appel is recommended but not required. (Link to ebook via Harvard University library; )

In most cases, the class materials should suffice. The instructor will provide the lecture slides after the lecture (or before if they are ready in time).

 

Expectations and Policies

The following sections describe expectations and policies for students in this course, as well as what you can expect from the course staff. Please get in touch if anything isn't clear.

General

  • We expect that you will do well in this course! 😀
  • We expect all students to stay up to date on the course material, as the assignments are based on material covered in lectures.
  • We expect you to look after yourself: sleep, eat, and keep well.
  • We expect you to reach out to course staff if you are having any difficulty in the class, whether it is about understanding the material, staying up to date on the material, external circumstances, or anything else that is affecting your engagement or performance in the course.
  • We expect you to read the syllabus, be aware of course policies, and follow them.
  • We expect you to engage in the course and make use of the course resources as needed, including sections, office hours, the discussion board, etc.
  • I very much appreciate the opportunity to get to know each of you during the course! Please try to stop by my office hours, or arrange a coffee or a meal, to get a chance to talk.

Attendance

College students are expected to attend lecture. Lectures will not be recorded. 

All students are expected to stay up to date on the course material, as the projects are based on material covered in lectures.

Devices in class: I appreciate that different people learn differently. For some students, using a device in class can be an effective learning aid (for example, to take notes). However, for many students, laptops and smart phones are a distraction. If you want to use a device in the classroom, you need to request permission via email; please describe how and why you intend to use the device.

Attendance at office hours and section is encouraged but not required.

Simultaneous Enrollment

Simultaneous enrollment in CS1530 is not possible this semester.

Projects

Projects are done individually: you must write all your own code. Do not share code with others (including letting others look at your code), do not accept code from others, and do not look for code online. However, you are encouraged to talk about the project with others, to share ideas and thoughts. All students should respect the Harvard academic integrity policy and the course collaboration policy below.

There may be opportunity for extra credit by augmenting your compilers (or the language we're compiling) with new features or optimizations. However, a word of warning: the extra credit only applies if the rest of the compiler is working.

Plan ahead and get the work done. We will not accept submissions that do not type-check and compile. See below for the late-minute and extension policy.

Late minutes, Penalties, and Extensions

Each student has 14,400 “late minutes” (which is the number of minutes in 10 days) which can be applied to any of the projects. A late minute extends the due date/time by 1 minute. At most 4,320 late minutes (= 3 days) can be used on any single project. (This allows us to grade your projects and return them to you within a reasonable period.)

Late minutes are intended to help you manage your time effectively. They are not meant to be a substitute for starting projects early.

Late minutes are not meant to be used for health issues (including mental health issues), family emergencies or other extenuating circumstances. In those situations, please contact the instructor.

Office Hours

You should come to office hours, both of Prof. Chong and of the Teaching Fellows! Office hours are a great opportunity to participate in the course and get to know course staff and other students!

You don't need to do much or any preparation to attend office hours. You are welcome to ask any kind of question: about understanding the material covered in lecture or in projects, about extensions to the ideas presented in the course, about how the material applies beyond the course, etc. You are welcome to work on your project during office hours but note that course staff may need to attend to other students during the office hours and may not be able to help you debug your code.

Office hours in this course are drop-in: you do not need to make an appointment; it is fine to just show up.

If you would like to attend office hours but can’t, please let us know! We can attempt to adjust our office hours, or to arrange a separate time to meet.

Seeking Help

If you find that you are struggling with understanding the material, or do not have enough time to spend on this course, or if there is anything going on in your life that is affecting your engagement with the course, please get in touch. We would rather hear from you early and often than only hear from you when you are in crisis.

Inclusive Learning and Accessibility

Your success in this class is important to me. If there are aspects of this course that prevent you from learning or exclude you, please let me know as soon as possible.

I encourage you to visit the Disability Access Office to determine how you could improve your learning; if you need official accommodations, you have a right to have these met.

If you have a letter from the Disability Access Office, please try to get that to me earlier rather than later. Concretely, please try to give it to me by the end of the second week of classes.

There are also a range of resources on campus. The Academic Resource Center provides many resources, including academic counseling and peer tutors. 

Mental Health

If you experience significant stress or worry, changes in mood, or problems eating or sleeping this semester, whether because of CS1530 or other courses or factors, please do not hesitate to reach out immediately, at any hour, to any of the course staff to discuss. Everyone can benefit from support during challenging times. Not only are we happy to listen and make accommodations with deadlines as needed, we can also refer you to additional support structures on campus, including, but not limited to:

  • The CAMHS Cares line 617-495-2042 is a 24/7 support line for Harvard students who have mental health concerns, whether they are in immediate distress or not, on-campus or elsewhere./a>
  • Harvard Peer Counseling

Financial Aid

We do not require that students purchase any books, hardware, or software. While not required, having one's own laptop is helpful. Students without their own laptops are encouraged to reach out at the start of the course to discuss possibilities. If your laptop breaks during the semester, HUIT may be able to provide a loaner laptop; contact the instructor for additional information.

Collaboration Policy

Discussion and the exchange of ideas are essential to doing academic work. For projects in this course, you are encouraged to consult with your classmates as you work on projects. However, after discussions with peers, make sure that you can work through the problem yourself and ensure that any answers you submit for evaluation are the result only of your efforts. In addition, you must cite any books, articles, websites, lectures, etc that have helped you with your work using appropriate citation practices. Similarly, you must list the names of students with whom you have collaborated on problems.

Do not pass solutions to problem sets nor accept them from another student. For programming projects, this means do not share code. Do not post course materials (including problem sets, solutions, exams, etc.) to websites (including public GitHub repositories, and similar) or course-content archives. Also, it is never okay to look up solutions to homework problems in this class, i.e., don't look on the web for solutions.

You can definitely engage in "high level" discussions with your peers, for example, about the problem statement. You can definitely engage in "low level" discussions with your peers, for example, about OCaml syntax and libraries, compiler error messages, etc. "Mid level" discussions require discretion and should be limited in this course.

Regarding the use of generative artificial intelligence (GAI) tools such as ChatGPT: these can be powerful and useful tools for programmers. However, a key pedagogical goal of this course is for you to develop a deep understanding of modern compilers through designing and implementing parts of a compiler. Towards this end, any use of GAI tools should be limited similarly to interaction with your peers: "low-level" support (e.g., correct syntax, use of library functions, etc.) is ok; "high-level" support (e.g., using GAI tools to summarize or clarify concepts to aid your understanding); "mid-level" support (e.g., designing and/or implementing significant parts of assignments) can undermine many of learning benefits of the assignments. When in doubt, disable GAI code suggestion tools. If you do use some form of code completion, please acknowledge and cite it when submitting your assignment. It is each student’s responsibility to assess the validity and applicability of any GAI output that is submitted; you bear the final responsibility. Violations of this policy will be considered academic misconduct. Different classes at Harvard may implement different AI policies, and it is the student’s responsibility to conform to expectations for each course. 

If you are ever in doubt, ask the course staff to clarify what is and isn't appropriate.