You are on page 1of 3

CS51 REFERENCE

0. Introduction

This document endeavours to get you up-to-speed on the basic tools necessary
to succeed in CS51. These will be useful throughout the class, so we recommend
you download or bookmark this for future reference!

5 1. Git and GitHub Classroom

GitHub Classroom is the platform CS51 uses to distribute problem sets. We also
expect students to version control their code using git and GitHub.

1.1. Accessing the distribution code. Each problem set specification, downloaded
from Canvas under Assignments, contains a link to the git repository for that
10 problem set. To download all of the materials for a problem set, all you need to do
is click on this link to the repository and on the right of the page above the problem
set files, you should see a Clone or Download option. Click on this option and
copy the https link to your clipboard. Open your terminal and navigate to the
folder where you want your problem set to be saved. Once there, execute:
15 $ git clone [URL from your clipboard] X
This will download the starter code for Problem Set X in a folder named X.

1.2. Working with a partner. On partner problem sets, one member of your pair
should follow the link on the problem set specification. After clicking this link
there is a Create team option. Once you enter a name for your team and submit it,
20 your partner can follow the link on the problem set specification and choose that
team.
If you want to work solo on a partner problem set, create a team for yourself.

1.3. Using git. Git is a version-control system that allows you to keep track of
your changes.
25 To keep track of your code, commit all your changes and push them to the git
repository by running git commit -am "commit message here" followed
by git push from the directory your files are in. Pushing your code to git is not
the same as submitting it for grading (see Using Gradescope section) but it is good
practice as it allows you to revert to earlier versions of your code and collaborate
30 more easily with your partner.
1
2 CS51 REFERENCE

If you want a succinct reference for your git usage, see Eddie Kohlers great
guide to Git, as well as TF Brian Yus video about git for CS 51.

2. Compiling with Make

In Problem Set 1, we provide a Makefile that allows you to compile your code
without directly calling ocamlbuild, the compiler that takes your .ml files and 35

turns them into executable .byte files.


For later problem sets, a Makefile might again prove helpful in compiling your
code, especially if you dont want to compile it all at once! Yet from now on,
you will be given the opportunity to write a Makefile yourself. Let us consider
the following sample Makefile (that not-so-coincidentally happens to to be a good 40

starting point for Problem Set 2!)


all: mapfold expression

mapfold: mapfold.ml
ocamlbuild mapfold.byte

expression: expression.ml
ocamlbuild expression.byte
Above, we see a Makefile with three targets:
all (called with make all or just make) compiles mapfold and expres-
sion, by listing mapfold and expression as dependencies.
mapfold (called with make mapfold) compiles only mapfold.ml. 45

expression (called with make expression) compiles only


expression.ml.
As you might be able to infer, the general structure of a Make rule is as follows!
target: first-dependency second_dependency [...]
<tab> shell-command <arguments>
You can add as many of your own rules as youd like, provided they are pre-
sented in the format above. 50

So, for example, you might have noticed that compilation produces a _build
folder and some annoying .byte files in your directory, which can be pesky to
manually delete. As such, you might want to consider including a make clean
target in your Makefile, which upon execution will automatically rm files you dont
need. You might also want to consider writing targets for your testing files, so you 55

can compile them as needed.


In problem sets, you will be expected to write your own Makefile if you want
one. We highly recommend this.
CS51 REFERENCE 3

3. Using Gradescope

60 Gradescope is the platform CS51 uses to grade problem sets and labs.

3.1. Submitting problem sets. In order to submit your problem set, log into
Gradescope and navigate to the Assignments tab on the side bar. From there you
should be able to access the relevant problem set and upload your .ml files. The
final submission before the problem set deadline will be graded. When problem
65 set grades are released you will be able to see your grade under the Assignments
tab on Gradescope.
Before submitting, please ensure your code compiles by running make while
in the main directory. Also be sure that any tests you have written run without
raising exceptions.
70 Evaluating definitions in the toplevel, while useful during development, does
not guarantee the code will compile. Submissions, or parts of submissions, that do
not compile will receive no credit!

3.2. Submitting labs. Labs are graded on participation and should be submitted
to Gradescope in the same way as the problem sets, however, upon submitting
75 your lab assignments Gradescope will display which tests you have passed or
failed.

4. Conclusion

If you have questions on anything in this document, Piazza is the place to be!

You might also like