COMP 311 Principles of Programming Languages (Fall 2009)

Professor Robert "Corky" Cartwright
Department of Computer Science
Rice University
Houston, Texas, USA
Fall 2007: Room 1046, Duncan Hall, MWF 1:00pm - 1:50pm

Course Information


Professor Robert "Corky" Cartwright
Email: corky.cartwright at gmail dot com
Office: DH 3104
Office Hours: Mondays, 9am–10am
Wednesdays, 9am–10am
Fridays, 9am–10am
By appointment

Teaching Assistants

Alina Sbirlea
Email: as44 at rice dot edu
Office: DH 3002
Office Hours: Mondays, 9am–11am
Sanjay Chatterjee
Email: cs20 at rice dot edu
Office: DH 2068
Office Hours: Tuesdays, 10am–12pm

Please try to arrive early during the scheduled office hours or let us know that you will be coming to talk to us.

Course Website and Contact Information

Course website:

Course mailing list: (subscribe

Email address to reach the entire teaching staff:

Note: The mailing list and the teaching staff email automatically block non-Rice email addresses to reduce the amount of spam. If you plan to send emails from a non-Rice email address, please write your name and the email address you want to use on a piece of paper and give it to a TA to unblock the address.

Check the website and the mailing list regularly. The assignments will be posted on the website, and the schedule will be adjusted as we go along. The mailing list is probably the fastest way to get help.

There is an archive of all discussions that have occurred on the mailing list available at, dating back to August 2005. Sometimes it may make sense to see what problems the students last year had.

Recommended Textbook

The recommended textbook for this class is:

Please also look at the additional references and the language resources on the course website.

Assignments, Exams, and Grading


The purpose of the homework is to deepen your understanding of the material introduced in class and to prepare you for the exams. The assignments will be posted on course website.


Generic Java (Java 6) is the only language that is acceptable for use in the assignments in this course. Scheme and OCaml are used in many examples given in lecture because they are more concise, but the same abstractions can be expressed equally well in Java. Students are expected to write their programs in the essentially same "mostly functional" style as well-written Scheme or OCaml code. Mostly functional Java programs rarely mutate the fields of objects or classes. A thorough understanding of the composite and visitor design patterns is a prerequisite to writing good solutions in Java. For tutorial guidance on how to write interpreters in Generic Java, see Prof. Cartwright's Notes on Object-Oriented Program Design.

Java 6 is an industrial strength language that supports "programming in the large". If you have taken Comp 211 or 212, then you have already been educated in how to write Java programs in a clean OO style. Java 6 supports generics, the parameterization of classes and methods by type and performs type checking at the level of parameterized types -- eliminating the need for the most common uses of casting in Java. You are expected to use generics wherever they help avoid explicit casting. The Java 6 compiler can be downloaded from the from Sun Microsystems.

The Java programming platform also includes an effective unit testing tool called JUnit which we expect you to use to test your Java programs. This tool is built in to DrJava. DrJava generates test class templates for you and will run all open unit test when you hit the "Test" button. We will only support the course submission software on CLE@R machines.

All assignments will be graded based on how they perform using the current releases of Java and DrJava.

We strongly encourage you to use pair programming on these projects, but we realize that scheduling constraints may make pairing impossible at times. Nevertheless, we expect both students on a team to understand every part of the project. Please employ good coding practices and document your programs extensively. Include a README file with your submission that explains how your project functions and how to invoke it. Test your program well! We will usually supply you with some test cases, but you are expected to add more.

Later projects heavily depend on earlier ones. Please make sure your projects are easy to use and extend (that's why good coding practices are important). For the first three projects, we will give you support code for the first project and solutions to the preceding project for the second and third projects. After that, you will have to use your own code.

The projects are due about every one and a half to two weeks. For an up-to-date schedule, please check the course website regularly. The assignments do not involve huge amounts of code, but the concepts behind them can be very deep. Please start early.

If you cannot find a partner, please email one of the teaching assistants or post to the mailing list. Groups of more than two students will not be allowed.


There will be two written take-home exams, one approximately in the middle of the semester, one during the last week of classes.


Your grade in this course will equally based on your performance on homework assignments and on the exams.

Slip Days and Late Submissions

Each student has seven (7) slip days that can be used for any homework assignments during the semester, exams excluded. An assignment that is submitted up to one day late will be accepted at the cost of one slip day. Similarly, an assignment that is submitted up to two full days late will be accepted at the cost of two slip days. A day consists of 24 hours; weekend days are included.

If a student has no slip days left, late submissions will not be accepted. If there are any extraordinary circumstances, please try to let us know in advance.

Recommendation: Save your slip days until the end of the term when the assignments are longer and more challenging.

Honor Code Policy

You are encouraged to talk with the lecturer, the teaching assistants, and to any classmates that you choose about the homework. Such conversations are to help you understand the lecture material, the homework problem, and possibly even the key idea for the solution. However, you are ultimately responsible for writing your own solutions in cooperation with your partner. You must do all work jointly with your partner; this stipulation includes every line of code. You and your partner are not permitted to copy the solution from another source.

How to Get Help

If you have a general question, please post to the mailing list at We will be monitoring it and by answering questions there, we can help the entire class. Since all students will be receiving your messages, you may also help each other, as long as you keep the Honor Code Policy outlined above in mind. Please subscribe so you can take part in the discussion.

If your question is of a personal nature or reveales part of the code of your solution, please DO NOT post to the mailing list (see Honor Code Policy). Instead, send an email to to reach the entire teaching staff.

Please note that non-Rice email addresses will automatically be blocked from sending to both and to protect the students and the teaching staff against spam. If you would like to use a non-Rice email address nonetheless, please write your name and the email address you would like to use on a piece of paper and hand it to a member of the teaching staff. We will then unblock that address.

Accomodations for Students with Special Needs

Students with disabilities are encouraged to contact the instructor or the teaching assistants during the first two weeks of class regarding any special needs. Students with disabilities should also contact Disabled Student Services in the Ley Student Center and the Rice Disability Support Services.

What You Should Watch Out For

Solutions in Java are straightforward to write but Java is a very wordy language so they require many more lines of code than the corresponding code in Scheme or OCaml. For this reason, most code fragments shown in class will be in Scheme or OCaml.

Start working on the projects early. While they do not involve huge amounts of code, the concepts behind them are very deep. Make sure your approach is correct.

Code well. While we provide solutions for the first 3 assignments, it's very will have to base later projects on code you have written in earlier assignments. Don't make it a pain to use later.

Test well. There often are intricate usage cases for some language constructs.

Make sure you stay in sync with the lecture material. Come to class, ask questions. You might be able to solve the projects without it, but the exams will get you.

Document your code and use good OO coding style (including the appropriate use of design patterns and Javadoc documentatoin). We will deduct points for bad style.

You can talk to the instructor, TAs, and even classmates about general concepts. Ultimately, however, you have to write your own solutions. For example, you cannot share code with anyone outside of your programming pair. This is not the only rule, it was just an example. If in doubt, ask first!

For the projects, you'll have to work in pairs and do pair programming for every part. Both partners have to know how each part of the program works.

Back to course website