Week 1

Week 4 – Classes and REPL

Readings & Due Dates

Read:

TODOs:

Lecture Materials

Lecture 7 (Tue 04/19) Handout

Lecture 7 (Tue 04/19) Note

Lecture 8 (Thu 04/21) Handout

Lecture 8 (Thu 04/21) NOte

Code Reviewing Another Compiler

In this assignment, you’ll spend time reflecting on, and learning from, the designs you and others chose for PA2.

We will make all of the PA2 compilers available to the class. We will make an effort to anonymize them, but if there are lots of comments, etc, with your name on them we may not be able to, and we may not be able to remove all traces of git history and other identifying information. You can provide us with a git repository that you anonymize if you’d like to manage this yourself.

You will be assigned 2 other compilers to review. Spend no more than 1 hour per compiler per prompt below (many will take much less than that). If you find yourself taking more, summarize and move on. The whole assignment shouldn’t take more than about 4 hours to complete, though you may want to spend more time than that reading and studying the compilers you are reviewing (and we encourage it)!

Your feedback will be shared with the class (including the author of the compiler), so make sure to keep what you write professional and constructive.

Assigned Compilers

All submitted compilers and the instructions for downloading them are available via this Piazza post.

Tracing the Compiler

For each of the compilers you are reviewing, choose two programs that run successfully on the compiler under review (e.g. they match ChocoPy’s behavior). Make sure that between them, they at least use:

  • Global variables
  • A function definition and function call
  • If or while
  • At least 2 different binary operators
  • An int and a bool

For each program you chose, show three relevant code snippets from the compiler that are critical to its compilation. For example, you might show the data structures used in the type checker, the code generation, and the parsing for a particular expression. Only choose the same snippet of code for both programs if it behaves in an interestingly different way across the two.

For each code snippet, write a sentence of how it relates to different parts of the program you’re testing.

You can use the same two programs on both compilers if you think they illustrate the behavior well.

Bugs, Missing Features, and Design Decisions

For each compiler you are reviewing, choose a program that has different behavior than the PA2 subset of ChocoPy (either produces an error, isn’t implemented, or produces a different answer).

  • If a key feature in the program isn’t implemented, describe how you would add it to the compiler (see below for how to do this).
  • If it is implemented but produces an error, describe how you could fix the error and make it produce the same answer as ChocoPy (see below for how to do this)
  • If it is implemented but produces the wrong answer, decide if you think this was a reasonable design decision. Describe as appropriate:

    1. If you think producing this answer instead made certain parts of the compiler design simpler or easier than matching ChocoPy, and identify how.
    2. If you think it’s just a bug, and if so, how to fix it.
    3. If you think it’s a better design decision than what was chosen by ChocoPy.
  • If you think the compiler perfectly implements the PA2 subset of ChocoPy, explain what you tested to reach this conclusion and why you are confident that it does.

Lessons and Advice

Answer the following questions:

  1. Identify a decision made in this compiler that’s different from yours. Describe one way in which it’s a better design decision than you made.
  2. Identify a decision made in this compiler that’s different from yours. Describe one way in which it’s a worse design decision than you made.
  3. What’s one improvement you’ll make to your compiler based on seeing this one?
  4. What’s one improvement you recommend this author makes to their compiler based on reviewing it?

Handin

You will this assignment as a PDF, first with the pages containing the review of the first compiler you were assigned followed by pages containing the review of the second. (We wish you could submit and label 2 pdfs but Gradescope doesn’t allow that).