Project paper

[Main project page]

Due: 5pm, Friday, December 7. Value: 60 pts. You should submit your paper to Moodle in PDF, OpenOffice.org, or Microsoft Word format.

For your assigned language, select a key feature of the language and write a tutorial of 2 single-spaced pages or more introducing the feature. (Naturally, 1.5 pages is not the same as 2 pages, and the paper should show no evidence of toying with format to stretch it out.) As you write, you should assume that the reader of the paper can readily write simple programs in the language but does not know about the feature in question. For instance, if my assigned language were Java, I might select generics, concurrency, or serialization as my feature to write about.

Note: You are required to talk with me (not e-mail!) to confirm your topic before you begin your project.

Code samples do not count as part of the length requirement. Instead, any substantial code example (defined as something that belongs on its own line, or that is more than 1/3 of a line long) should be placed into an appendix and referenced as “Sample 1” (or whichever number it is) in your text. The following example illustrates.

When threads access memory concurrently, this can lead to conflicts as illustrated in Sample 1. In this example, a global variable total could be modified through two different threads entering incrementTotal nearly simultaneously. In this case, each thread could retrieve the initial total value into a register, increment its register, and then save its value; the net effect is that total goes up by one even though incrementTotal has executed twice!

The synchronized keyword can resolve such a conflict: We place synchronized(object) {} around such memory references. Sample 2 illustrates this: We create an object named totalLock (synchronized works only on objects) and enclose the reference to total in a synchronized block. Before a thread attempts the “total += 1;” statement, it must first acquire the lock associated with totalLock. If another thread enters incrementLock soon thereafter, it will not be able to acquire totalLock's lock held by the first thread, so it must wait until the first one has completed the “total += 1;” statement and released its lock. Only then can the second thread can acquire the lock and proceed to execute “total += 1;” for itself. This prevents the bug found in Sample 1.

Appendix: Code samples

Sample 1

int total = 0;

int incrementTotal() {
    total += 1;
}

Sample 2

Object totalLock = new Object();
int total = 0;

int incrementTotal() {
    synchronized (totalLock) {
        total += 1;
    }
}

Your paper should also include an annotated bibliography. This does not count as part of your main text. An annotated bibliography includes a citation of the source using a standard bibliographic format (such as MLA, APA, or something else — any established academic standard is fine) followed by a couple of sentences describing the source and how it was useful to you. It is helpful if the description establishes the source's authority.

Bloch, Joshua. Effective Java. Indianapolis: Pearson, 2004.
This book describes several pitfalls for Java programming, including six items regarding concurrency. The author was an software designer for Sun, where he designed the java.util package.

The bibliography would normally include around five to seven resources, though I could imagine fewer for a language that presents truly unusual challenges.

You do not need to include citations in your tutorial, except of course for quotations or copied examples where failing to cite would be plagiarism. Your tutorial, naturally, should be your own work and not simply a rehashed version of tutorials that have already been written.

This paper is worth 60 points, divided as follows.

25 points Style

Is the tutorial formatted well and use grammar correctly? Is it written in a way that captures a reader's interest? Is it structured cleanly?

25 points Content

Did you consult me before beginning, having a good idea for a possible topic for your tutorial? Do you discuss worthwhile, academically interesting concepts? Do you provide enough detail to understand the topic well? Do you explain why the feature is useful?

10 points Bibliography

Does your bibliography demonstrate the use of multiple sound resources? Are the annotations useful in understanding what the resource contributed? Do the citations follow an established format? Are the annotations written well?

60 points TOTAL