Programming Languages and Compilers

CS 164 @ UC Berkeley, Fall 2021

This is the Fall 2021 website. If you are currently taking CS 164, please go to


Have you ever wondered why C programs seem to run faster than Python programs? Have you ever been confused by an error message and wondered why Java couldn’t understand your program? In CS 164, we’ll learn how compilers take in code in one language and produce code in another; in particular, we’ll learn how to translate high-level languages into code that your computer’s processor can understand. We’ll get hands-on practice developing compilers for a series of increasingly complex languages. Along the way, we’ll learn some general best practices for developing and testing complex software systems.

High-Level Information

Table of Contents

  1. Learning Objectives
  2. Course Culture
  3. Logistics
  4. Assignments, Exams, and Grading
  5. Accommodations
  6. Getting Help
  7. Collaboration Policy
  8. Course Announcements
  9. Resources
  10. Acknowledgments!

Learning Objectives

After completing this course, students will be able to:

Course Culture

Students taking CS 164 come from a wide range of backgrounds. We hope to foster an inclusive and safe learning environment based on curiosity rather than competition. All members of the course community—the instructor, students, and GSIs—are expected to treat each other with courtesy and respect. Some of the responsibility for that lies with the staff, but a lot of it ultimately rests with you, the students.

Be Aware of Your Actions

Sometimes, the little things add up to creating an unwelcoming culture to some students. For example, you and a friend may think you are sharing in a private joke about other races, genders, or cultures, but this can have adverse effects on classmates who overhear it. There is a great deal of research on something called “stereotype threat,” which finds simply reminding someone that they belong to a particular culture or share a particular identity (on whatever dimension) can interfere with their course performance.

Stereotype threat works both ways: you can assume that a student will struggle based on who they appear to be, or you can assume that a student is doing great based on who they appear to be. Both are potentially harmful.

Bear in mind that diversity has many facets, some of which are not visible. Your classmates may have medical conditions (physical or mental), personal situations (financial, family, etc.), or interests that aren’t common to most students in the course. Another aspect of professionalism is avoiding comments that (likely unintentionally) put down colleagues for situations they cannot control. Bragging in open space that an assignment is easy or “crazy,” for example, can send subtle cues that discourage classmates who are dealing with issues that you can’t see. Please take care, so we can create a class in which all students feel supported and respected.

Be an Adult

Beyond the slips that many of us make unintentionally are a host of behaviors that the course staff, department, and university do not tolerate. These are generally classified under the term harassment; sexual harassment is a specific form that is governed by federal laws known as Title IX.

UC Berkeley’s Title IX website provides many resources for understanding the terms, procedures, and policies around harassment. Make sure you are aware enough of these issues to avoid crossing a line in your interactions with other students. For example, repeatedly asking another student out on a date after they have said no can cross this line.

Your reaction to this topic might be to laugh it off, or to make or think snide remarks about “political correctness” or jokes about consent or other things. You might think people just need to grow a thicker skin or learn to take a joke. This isn’t your decision to make. Research shows the consequences (emotional as well as physical) on people who experience harassment. When your behavior forces another student to focus on something other than their education, you have crossed a line. You have no right to take someone else’s education away from them.

This issue is very important to CS164’s course staff. Therefore, if we cannot appeal to your decency and collegiality, let us at least appeal to your self-interest. Do not mess around on this matter. It will not go well for you.

Issues with Course Staff

Professionalism and respect for diversity are not just matters between students; they also apply to how the course staff treat the students. The staff of this course will treat you in a way that respects our differences. However, despite our best efforts, we might slip up, hopefully inadvertently. If you are concerned about classroom environment issues created by the staff or overall class dynamic, please feel free to talk to us about it. The instructor and the head GSI in particular welcome any comments or concerns regarding conduct of the course and the staff.

We are committed to creating a learning environment welcoming of all students that supports a diversity of thoughts, perspectives and experiences and respects your identities and backgrounds (including race, ethnicity, nationality, gender identity, socioeconomic class, sexual orientation, language, religion, ability, and more.) To help accomplish this:

We will take all complaints about unprofessional or discriminatory behavior seriously.


The Classroom

Our time in the classroom will be a mix of traditional lecture and discussion-based activities. Please come to class ready to engage with the material and ask questions about things you don’t understand. The pre-class drills (discussed below) should help you with this!

Time Expectations

In addition to 3 hours a week in lecture and 1 hour a week in section, students will be expected to spend 6–8 hours a week outside of class on homework and drills, plus an average of 2 hours per week studying for the midterm and the final exam.

Required Materials

There is no textbook for the course; all readings will be provided digitally.

You will need access to a computer in order to complete the assignments. If you do not have access to a computer, please contact Berkeley Student Technology Services about acquiring a loaner laptop. Also consider contacting the Berkeley Student Technology Fund.

Assignments, Exams, and Grading

All assignments will be posted and handed in online. Approximate grading weights for each type of assignment are listed below.

Homeworks will be due on Wednesdays at 9pm. Homeworks will be due either a week or two weeks after they are released, and there will never be more than one homework out at a time. Online drills will be due at noon (12pm) on Friday. (So if you’re a late sleeper, please plan on doing them the day before!)

Drills (10%)

Drills are short online quizzes that will be due shortly before class every Friday. These should take around 30 minutes to complete, and are designed to help us—and you!—understand which topics you’ve already understood vs. which topics we might need to cover more deeply in class.

Drills will be graded for completion; you will get credit as long as you appear to be taking them seriously. You can miss one drill and still get full credit for this part of the class.

Homework Assignments (60%)

Homeworks, due every week or two, are programming projects designed to help you learn the material by putting it into practice. Programming assignments will be graded for correctness and test quality. Occasionally, some of your homeworks will include short, written reflections related to the course material. These will be graded lightly—we’re asking you to think seriously and carefully, but not to write formal papers. Homework assignments should be completed and handed in individually. (But see the collaboration policy below—you are free to discuss the homeworks with your classmates!) We will use the terms “homework,” “assignment,” and “project” interchangeably.

Exams (30%)

There will be two exams: a midterm and a final.

The midterm will count for 12% of the grade, and the final will count for 18% of the grade. We have a “clobber” policy, so if you get a higher grade on the final than on the midterm, the final score will be used for both your midterm and your final. (Note that it doesn’t go the other way. Exam scores from earlier in the semester never replace exam scores from later in the semester.)

Late Assignments

Each student will have five “late days” that can be used throughout the semester on homeworks. Each late day allows the student to hand in a homework one day late. No more than three can be used on an individual assignment. Fill out this form to use late days on a given assignment. If you want to use late days, you have until 3 days (72 hours) after the original deadline to submit the late days form.

If your assignment is handed in late, you have not submitted the late days form by 72 hours after the original deadline, and you have not been granted an extension (see below), your assignment will not be graded. Likewise, if your assignment is handed in late, you are out of late days, and you have not been granted an extension (see below), your assignment will not be graded.

Note: Once your submission has been graded, we will not grade it again. So if you submit before the Wednesday deadline, but you want to use late days, you must overwrite your submission before the autograder runs on Thursday (see Autograder and Withdrawing a Submission). Otherwise, your grade will be based on the version submitted before the original Wednesday deadline. Once the autograder has run on your submission, that grade is always final.


Please use the extensions form to request extensions. Requests for routine issues such as work in other courses or interviews will come out of your allotment of 5 late days, so no email is required. (Just fill out the form linked above.) Extensions for substantial illnesses and disruptive life events will be granted on a case-by-case basis. If you think you need an extension on an assignment, please submit the extensions form as early as possible.

Anonymous Grading

All homeworks will be graded anonymously. Please do not include identifying information with your homework submission.

Regrade Requests

You are encouraged to look over your assignments after they have been graded. If you find a possible error or believe that you lost too many points, please submit a regrade request through the course hand-in software. You must initiate such inquiries within one week of receiving your grade. The grading will be freshest in your GSIs’ minds during this time, and this prevents a backlog of requests from arising towards the end of the semester.


We honor and respect the different learning needs of our students, and are committed to ensuring you have the resources you need to succeed in our class. If you need religious or disability-related accommodations, if you have emergency medical information you wish to share with us, or if you need special arrangements in case the building must be evacuated, please share this information with us as soon as possible at


If you have physical, psychological, or learning disabilities that could affect your performance in the course, we urge you to contact See more information under the “DSP” section of “Resources” farther down this page.

Religious Observance

If you require accommodation for religious observance, please contact at least a week before the deadline in question to make arrangements.

Personal Emergency

In the event of a medical or family emergency, contact to work out accommodations.

Getting Help

Our goal, as a course staff, is for every student to do well in the class. As such, we encourage you to ask questions about anything you don’t understand. Whether you are confused by something from lecture or are having trouble with an assignment, please reach out to us!


Our course uses Piazza for online discussions.You can use it to ask questions about course concepts, assignments, and logistics. Posts can be either public or private; public posts are visible to everyone, while private posts are visible only to course staff. Almost all posts should be public. Any questions having to do with your particular solution to an assignment should be private. All other posts should be public. (If you have a question about something, it’s very likely that other students do, too!) The course staff may make your private posts public if the answer is of general interest.

Piazza is a discussion forum, so please feel free to respond to each others’ questions and comments! It’s great when students can learn from each other! When doing so, keep in mind the Course culture guidelines.

Posts made on Piazza after 9pm will not get a course staff response until the next day.


Please post questions about the course to Piazza rather than emailing the course staff—it’s very useful to have all course questions in one place where any of us can answer them. If you are unable to log in to Piazza, you can contact the whole course staff at

Extensions should be requested not by email but via the extension form: the extensions form.

Email related to accommodations should go to

If you have concerns of a personal nature (such as a problem with another student), please email, the head GSI (, or the instructor (

Office Hours

GSIs will offer office hours each week. Sarah will also have open office hours. Each week’s schedule is available here. We may adjust the office hour schedule throughout the semester as we do mid-semester surveys to understand student needs and preferences!

Please come to office hours! Coming to office hours does not send a signal that you are behind or need “extra help.” On the contrary, coming to office hours early and often tends to co-occur with success in the course!

Feel free to come to Sarah’s office hours even if you don’t have a specific question about an assignment. Sarah is happy to chat about the course material, computer science in general, careers in computer science, or whatever other computer-y topics are on your mind.

Collaboration Policy

Drills should be done alone and without collaboration, since they are designed to help us shape the course by understanding whether you‘ve internalized the concepts you’ll need for the next lecture. And remember that they‘re graded for completion!

Homeworks are completed individually. We encourage students to talk about the assignments at a high level and to assist each other with debugging—for instance, talking about why code doesn’t compile or why a test is failing. Students should not, however, share code or try to find solutions on the Internet.

The following examples of collaboration are allowed:

The following examples are not allowed:

Exams are completed individually.

If you have questions about the boundaries of the policy, please ask. There is never a penalty for asking! We’re always happy to clarify.

Autograder + Solution Similarity Checker

The autograder runs on Thursdays and Sundays. Homeworks are due Wednesdays, so you'll usually get feedback when the autograder runs Thursday. If you've used some late days, and you submit your assignment after the Thursday run, expect your feedback on Sunday.

The autograder has a built-in checker that assesses the similarity of your solutions to solutions by other students in the course (and a variety of other resources including Internet resources and prior students’ solutions). If the autograder finds a high similarity with another solution, all students with involved solutions will receive an automated email with the subject line “The 164 autograder has found something strange in your solution.” If you receive such an email, it is your responsibility to reach out to to schedule a meeting to discuss your solution within 7 days of receiving the email. Note that this may occur either when the autograder runs on your solution or on another student’s solution. If no violation of the collaboration policy occurred, we’ll clear it up in the meeting you schedule. If a violation of the collaboration policy occurred or if you don't contact us within 7 days, we’ll go through the CSC process.

Withdrawing a Submission

Sometimes in the midst of stressful circumstances, we may make a mistake. You can withdraw a homework submission before the autograder runs by overwriting your submission on Gradescope with the assignment's starter code. You do not need to provide an explanation. If you withdraw a submission, the submission will automatically receive a 0, and the autograder will not run on your submission.

You can fill out this form if you would like to withdraw an exam from grading. In the case of an exam, you must fill out the form within 48 hours of when you completed the exam.

What Happens in the CSC Process?

This varies from case to case. See this page for details. A starting point for sanctioning for undergraduate students is: (i) First violation: Non-Reportable Warning and educational intervention, (ii) Second violation: Suspension/Disciplinary Probation and educational interventions, (iii) Third violation: Dismissal. But again, this varies from case to case.


We run the autograder on Thursdays and Sundays, and whatever you’ve submitted at those times will be autograded and checked for similarity. If you don’t want your submission to be autograded or checked, do not submit it. If you don’t want it to be autograded or checked, and you’ve already submitted it, withdraw it by overriding your submission on Gradescope with the assignment's starter code before the autograder runs.

Please Don’t Cheat

We’re sorry this section of the syllabus is so sad. We don’t like it either. But it’s upsetting to students if other students are cheating, so we’ve built the similarity checker into the autograder. Please don’t cheat, and then none of us will have to deal with all this.

And again, if you have questions about the boundaries of the collaboration policy, please ask! There is never a penalty for asking!

Course Announcements

Course announcements will be made via Piazza. Time-sensitive announcements will also go out via email.

The course staff may issue clarifications to assignments up to 48 hours before the due date.


Important Note: We are committed to being a resource to you, but it is important to note that all members of the teaching staff for this course are responsible employees, meaning that we must disclose any incidents of sexual harassment or violence to campus authorities. If you would like to speak to a confidential advocate, please consider reaching out to the Berkeley PATH to Care Center.

Basic Needs Center

The Basic Needs Center (lower level of MLK Student Union, Suite 72) provides support with all the essential resources needed to not only survive, but thrive here at UC Berkeley. Their mission is to support you and work together towards justice and belonging for all. They define Basic Needs as the essential resources that impact your health, belonging, persistence, and overall well being. It is an ecosystem that includes: nutritious food, stable housing, hygiene, transportation, healthcare, mental wellness, financial sustainability, sleep, and emergency dependent services. They refuse to accept hunger, homelessness, and all other basic needs injustices as part of our university.

Berkeley International Office (BIO)

The mission of the Berkeley International Office (2299 Piedmont Avenue, 510-642-2818) is to provide support with all the essential resources needed to not only survive, but thrive here at UC Berkeley. Their mission is to support you and work together towards justice and belonging for all. They define Basic Needs as the essential resources that impact your health, belonging, persistence, and overall well being. It is an ecosystem that includes: nutritious food, stable housing, hygiene, transportation, healthcare, mental wellness, financial sustainability, sleep, and emergency dependent services. They refuse to accept hunger, homelessness, and all other basic needs injustices as part of our university.

Center for Access to Engineering Excellence (CAEE)

The Center for Access to Engineering Excellence (Bechtel Engineering Center 227) is an inclusive center that offers study spaces, nutritious snacks, and tutoring in >50 courses for Berkeley engineers and other majors across campus. The Center also offers a wide range of professional development, leadership, and wellness programs, and loans iclickers, laptops, and professional attire for interviews.

Counseling and Psychological Services (CAPS)

The staff of the UHS Counseling and Psychological Services (Tang Center, 2222 Bancroft Way; 510-642-9494; for after-hours support, please call the 24/7 line at 855-817-5667) provides confidential, brief counseling and crisis intervention to students with personal, academic and career stress. Services are provided by a multicultural group of professional counselors including psychologists, social workers, and advanced level trainees. All undergraduate and graduate students are eligible for CAPS services, regardless of insurance coverage.

To improve access for engineering students, a licensed psychologist from the Tang Center also holds walk-in appointments for confidential counseling in Bechtel Engineering Center 241 (check here for schedule).

COVID-19 Resources and Support

You can find UC Berkeley’ COVID-19 resources and support here.

Disabled Students’ Program (DSP)

The Disabled Students’ Program (260 César Chávez Student Center #4250; 510-642-0518) serves students with disabilities of all kinds, including mobility impairments, blind or low vision, deaf or hard of hearing; chronic illnesses (chronic pain, repetitive strain injuries, brain injuries, AIDS/HIV, cancer, etc.) psychological disabilities (bipolar disorder, severe anxiety or depression, etc.), Attention Deficit Disorder/Attention Deficit Hyperactivity Disorder, and Learning Disabilities. Services are individually designed and based on the specific needs of each student as identified by DSP’s Specialists. The Program’s official website includes information on DSP staff, UCB’s disabilities policy, application procedures, campus access guides for most university buildings, and portals for students and faculty.

Educational Opportunity Program (EOP)

The Educational Opportunity Program (Cesar Chavez Student Center 119; 510-642-7224) at Cal has provided first generation and low income college students with the guidance and resources necessary to succeed at the best public university in the world. EOP’s individualized academic counseling, support services, and extensive campus referral network help students develop the unique gifts and talents they each bring to the university while empowering them to achieve.

Gender Equity Resource Center (GenEq)

The Gender Equity Resource Center, fondly referred to as GenEq, is a UC Berkeley campus community center committed to fostering an inclusive Cal experience for all. GenEq is the campus location where students, faculty, staff and Alumni connect for resources, services, education and leadership programs related to gender and sexuality. The programs and services of the Gender Equity Resource Center are focused into four key areas: women; lesbian, gay, bisexual, and transgender (LGBT); sexual and dating violence; and hate crimes and bias driven incidents. GenEq strives to provide a space for respectful dialogue about sexuality and gender; illuminate the interrelationship of sexism, homophobia and gender bias and violence; create a campus free of violence and hate; provide leadership opportunities; advocate on behalf of survivors of sexual, hate, dating and gender violence; foster a community of women and LGBT leaders; and be a portal to campus and community resources on LGBT, Women, and the many intersections of identity (e.g., race, class, ability, etc.).

Multicultural Education Program

The Multicultural Education Program (MEP) is one of six initiatives funded by the Evelyn and Walter Haas, Jr. Fund to work towards institutional change and to create a positive campus climate for diversity. The MEP is a five-year initiative to establish a sustainable infrastructure for activities like educational consultation and diversity workshops for the campus that address both specific topics, and to cater to group needs across the campus.

Ombudsperson for Students

The Ombudsperson for Students (Sproul Hall 102; 510-642-5754) provides a confidential service for students involved in a University-related problem (academic or administrative), acting as a neutral complaint resolver and not as an advocate for any of the parties involved in a dispute. The Ombudsperson can provide information on policies and procedures affecting students, facilitate students’ contact with services able to assist in resolving the problem, and assist students in complaints concerning improper application of University policies or procedures. All matters referred to this office are held in strict confidence. The only exceptions, at the sole discretion of the Ombudsperson, are cases where there appears to be imminent threat of serious harm.

PATH to Care Center

The PATH to Care Center (510-642-1998) offers Confidential Care Advocates providing affirming, empowering, and confidential support for survivors and those who have experienced gendered violence, including sexual harassment, dating and intimate partner violence, sexual assault, stalking, and sexual exploitation. Advocates bring a non-judgmental, caring approach to exploring all options, rights, and resources.

Care Line (PATH to Care Center)

The Care Line (510-643-2005) is a 24/7, confidential, free, campus-based resource for urgent support around sexual assault, sexual harassment, interpersonal violence, stalking, and invasion of sexual privacy. The Care Line will connect you with a confidential advocate for trauma-informed crisis support including time-sensitive information, securing urgent safety resources, and accompaniment to medical care or reporting.

Social Services

Social Services provides confidential services and counseling to help students with managing problems that can emerge from illness such as financial, academic, legal, family concerns, and more. They specialize in helping students with pregnancy resources and referrals; alcohol/drug problems related to one’s own or a family member’s use; sexual assault/rape; relationship or other violence; and support for health concerns-new diagnoses or ongoing conditions. Social Services staff will assess a student’s immediate needs, work with the student to develop a plan to meet those needs, and facilitate arrangements with academic departments and advocate for the student with other campus offices and community agencies, as well as coordinate services within UHS.

Student Learning Center (SLC)

As the primary academic support service for undergraduates at UC Berkeley, the Student Learning Center (510-642-7332) assists students in transitioning to Cal, navigating the academic terrain, creating networks of resources, and achieving academic, personal, and professional goals. Through various services including tutoring, study groups, workshops, and courses, SLC supports undergraduate students in Biological and Physical Sciences, Business Administration, Computer Science, Economics, Mathematics, Social Sciences, Statistics, Study Strategies, and Writing.

Student Technology Equity Program (STEP)

The Student Technology Equity Program connects laptops, Wi-Fi hotspots, and other required technology to students in need.

UC Berkeley Food Pantry

The UC Berkeley Food Pantry (#68 Martin Luther King Student Union) aims to reduce food insecurity among students and staff at UC Berkeley, especially the lack of nutritious food. Students and staff can visit the pantry as many times as they need and take as much as they need while being mindful that it is a shared resource. The pantry operates on a self-assessed need basis; there are no eligibility requirements. The pantry is not for students and staff who need supplemental snacking food, but rather, core food support.

Undocumented Students Program (USP)

The Undocumented Students Program (119 Cesar Chavez Center; 642-7224) practices a holistic, multicultural and solution-focused approach that delivers individualized service for each student. The academic counseling, legal support, financial aid resources and extensive campus referral network provided by USP helps students develop the unique gifts and talents they each bring to the university, while empowering a sense of belonging. The program’s mission is to support the advancement of undocumented students within higher education and promote pathways for engaged scholarship.


Much of the design and content of this course is adapted with permission from materials developed by Doug Woos.

Much of the infrastructure for this course is adapted with permission from materials developed by

Much of the content in this document is adapted with permission from materials developed by Doug Woos, Kathi Fisler, and Shriram Krishnamurthi.