Sunteți pe pagina 1din 7

CS51 Problem Set 0

Due Friday, February 6, 2015, 5:00 pm

Introduction

Welcome to CS51! The goal of this assignment is to prepare your development environment
for use in CS51. You will set up an editing environment for OCaml, compile and run a toy
program, explore git, and figure out the assignment submission system.

Part 1: Announcements

Upcoming Sections

There will not be regular sections or office hours during the week of February 1st.
Should you need help on this problem set, please attend the Problem Set 0 help session
on Tuesday, February 3, 7-8:30pm in Northwest Building B103. If you have questions
at any other time of the week, please turn to Piazza (discussed below).

Todos

College students: please fill out the sectioning form for CS51 here. Sectioning will be
available from Tuesday, February 3 at 2:30pm until Thursday, February 5 at 11:59pm.
Check out Piazza, the discussion board used by this course, here. Piazza will be your
go-to source if you have a question about a problem set or anything else in the course.
We encourage you to answer questions and contribute to discussions on Piazza (and
you might even find it beneficial to your grade at the end of the semester).
Fill out the CS51 Welcome Survey.

Part 2: Setting up your Development Environment

The supported way to complete work for CS51 is to use the 2014 CS50 Appliance, with
CS51 tools installed.
If you took CS50 last fall (2014):
Fire up your Appliance.
Look at the bottom right corner of the screen for a version number. If it
starts with 2014, follow these steps:
Open a Terminal window in the appliance, and type:
sudo apt-get update
sudo apt-get install deb51
update51
Be patient! It may take 30 to 60 minutes to get the environment setup.
Once installation is finished, close that terminal window and open a new
one.
If the version of your appliance is anything other than 2014, head over here for Macs,
and here for PCs, where you can download the CS50 Appliance. If you are on a Mac
and do not have VMware Fusion, please fill out https://cs50.harvard.edu/vmware to
get a license. In the meantime, you should be able to use the free trial for VMware
Fusion. Once your Appliance is running, follow the previously mentioned steps to get
set up for CS51!
You are welcome to "do your own thing" if you have no qualms about setting up
OCaml, OPAM, utop, core, etc. as specified in the course textbook. However, please
note that we can provide no support to students who elect this option. If you have
trouble with your setup, we will not be able to help you.

Once you have your Appliance set up, test OCaml by running utopfrom the command
line (Terminal). Don't forget to open a new terminal window after installation, or the
following won't work! You should eventually see the prompt:
utop #

If you type

"are we there yet?";;

you should get the output:


- : string = "are we there yet?"

Congratulations! If you got this far, OCaml works. Type

#quit;;

at the prompt (including the # sign) or Ctrl-D to exit OCaml. Now you just have to learn
how to write useful programs.

Part 3: Your First OCaml Program (and Source Control)!


Set up Git

As software projects get larger, it's desirable to have software that can track the
development of the project (i.e., new files, changes, deletions). Gitis an example of
version control software which does just that. Gitallows you, the developer, to track
changes to your code, in the form of "commits."

A central idea to version control systems is the notion of a repository, which is a place
where code – and its history – is stored. In CS51, we will be using
code.seas.harvard.edu, which provides Gitrepositories to students. As we will see,
this Gitrepository will be a place where you can store incremental versions of your
problem sets. It will be a place where you can pushyour code at all stages of the
development process for the sake of backing up your code. Gitexcited!

To begin using Gitfor CS51, you'll first need an account on code.seas.harvard.edu.


If you already have one, you can skip these steps:

1. Navigate to the login page.


2. You'll be prompted for your FAS username. If you don't have a FAS account,
register for one here! Enter your username, and you'll be redirected to an
OpenID page.
3. Once at the OpenID page, enter your password. You should be redirected to
your Dashboard within code.seas, after possibly seeing some profile questions.

Now that you have an account on code.seas, you'll need to add an SSH key, which
will allow you to authenticate from your Appliance securely!

1. At the command line (Terminal) in the CS50 Appliance, run ssh-keygen.


2. Follow the instructions to generate your key. Pressing enter at each stage will
specify the default configuration.
3. Once your key is generated, run cat ~/.ssh/id_rsa.pub(assuming you stored
your key in the default place) to see your public key. Copy this value to the
clipboard.
4. On your code.seasaccount's Dashboard, select "Manage SSH keys." Click "Add
SSH key" on the left hand side, and then paste your key that you copied onto the
clipboard.
5. Save. Then, after refreshing your page, you should see that the key is Ready!

Now, it's time to make a personal clone of the cs51-psetsrepository.


1. Go to https://code.seas.harvard.edu/cs51-2015/psets. Be sure you're still logged
in.
2. Click the "Clone repository" button on the right side.
3. You should see a new screen prompting you to name the clone that you are
creating. Feel free to use the default name (usernames-psets) or customize it! You
may want to add "51" to the title.
4. In just a minute, you'll see a page with details about your repository. Copy that
SSH "Clone & push" URL to the Clipboard.
5. Click the "Manage Read Access" button in the right sidebar. On the page that
loads, click the "Make Private" link. If you see your name instead of (or after
clicking) the "Make Private" link, your repository is private!
6. Although your repo is private, you do need to provide staff with the ability to
read it for grading purposes. On this same page (Manage Read Access), add the
cs51-2015-staffteam by clicking the "Add a team" link, type cs51-2015-staff,
and click "Grant read access".

Did you grant the staff read access to your repo?

1. Double-check that you successfully made your repo private but gave the cs51-
2015-staffteam read access to your repo, or you will be unable to submit
problem sets!

Now, it's time to get a local copy of the clone you made.

1. In the CS50 Appliance, make your way over to the command line (Terminal).
2. Let gitknow who you are.
Execute git config --global user.name "YOUR FULL NAME".
Execute git config --global user.email "YOUR HARVARD EMAIL ADDRESS".
Execute git config --global push.default matching.
You should use your Harvard email address and full name.
3. Type git clone CLONE_URL, where CLONE_URLwas the SSH "Clone & push URL"
that you copied on the Clipboard before.
4. You should see something like this if the clone went well (potentially after typing
"yes" when prompted to continue connecting):
Cloning into 'usernames-psets'...
remote: Counting objects: 51, done.
remote: Compressing objects: 100% (51/51), done.
remote: Total 51 (delta 51), reused 51 (delta 51)
Receiving objects: 100% (51/51), 51 MiB | 51 MiB/s, done.
Resolving deltas: 100% (51/51), done.
If you see something like the following, make sure you properly added your SSH
keys.
Cloning into 'usernames-psets'...
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: The remote end hung up unexpectedly

5. If you list the contents of your directory now (as with ls), you should see a new
directory whose name matches what you called your repository.

Your First OCaml Program

After completing those steps, you should now have a 0directory with a ps0.mlfile
inside. Your job is to edit this file, setting all the variables to appropriate values. First,
though, check that the file compiles.
If you're using emacs, compile the entire file using C-c C-b (which is emacs-speak for
hitting Ctrl+c and then Ctrl+b). Otherwise, use the provided Makefile by typing make
in the ps0directory:
$ make
corebuild ps0.native

$ ./ps0.native
----------------------------------------
Name: FIRST LAST

Year: Other: I haven't filled it in yet

I'm excited about ....!


----------------------------------------

Now enter values for name, class_year, and exciting. If using emacs, you can evaluate
individual functions with C-c C-e. Once finished, make sure the file still compiles.

How To Use Git

When you modify some code, or reach a good "checkpoint" in your coding (e.g., "fixed
that bug!"), you can "commit" these changes by executing

git commit -am "some message here"

at the Appliance Terminal.


The -aflag here specifies that gitshould take note of all of the changes made in files
that you have previously told gitto track.
You can tell gitto track a file named filenameby adding it, as in git add
filename.
Since ps0.mlwas already added to the repository, you don't have to addit again.
However, if you made a new file, you would have to addit.
You can addall of the files in your current directory (and subdirectories) to your
repository by using git add --all. This is probably the safest thing to do (to
ensure you're tracking everything), but you'll probably not want to track the
compiled binaries.
The -mflag, followed by some string, specifies a commit message, which is a short string
describing the changes that have been made since the last commit. This can be useful
in keeping track of exactly what changes you make throughout the development
process. If you work on projects with other people, they can see what other changes
you've made by reading these commit messages, which they (and you!) can see by
running git log.
Merely committing will store these changes in your local computer's copy of the
repository. To "push" this repository's changes online to code.seas, execute git push.
Resources for learning more about git:
CS61 Git Resource
Official gitwebsite
Academic Computing tutorial
gitImmersion

Part 4: Submitting

This year, we're using a submission tool originally built for CS61. After an initial
configuration, it allows you to automatically submit when you git pushyour work to
code.seas. As a result, you'll only need to perform most of the below steps below only once.
Let's get started!

One-time setup instructions

1. Go to the submit tool: http://harvardcs.hotcrp.com/cs51/2015/.


2. Enter your Harvard email address (the same one you used to configure git) in the
email field, select Create an account, then click the Create accountbutton.
3. Check your email (it might take a few minutes) for login credentials from the server. If
you must: sneer at, but ultimately accept, the security of the authentication ... it may
change in the future, and we will communicate with you if it does.
4. Once you've received the credentials, return to the grading site and login.
5. You should see a text field called repositoryto input the URL of your code repo from
code.seas. Visit your repository, and paste the clone URL (remember CLONE_URL
from before?) into this field, and click Save.
6. If all goes well, you should see a reference to your last commit in the grade tool. The
most common errors are that you did not provide the cs51-2015-staffteam with read
access to your repo or you did not configure git to use the same email address as you
used for the grade tool.

Recurring submission steps

1. When you're ready to submit, be sure to commit all changes to the files in the 0
directory of your repo, and do a git pushto push those changes to the code.seas
server.
2. After a few short moments after a successful git push, the grade tool should
automatically detect and show you the commit. You're done!

S-ar putea să vă placă și