Object-oriented (OO) programming has emerged as a significant software development methodology. The goal of this course is to learn how to build and evolve large-scale programs using object-oriented programming. To this end, the course introduces the important concepts of object-oriented languages and design, and explores how these concepts are implemented.
Prerequisites: Computer Systems Organization (CSCI-UA 201).
In exploring object-oriented programming, we investigate three questions:
Design and primitives matter because they represent the essence of object-oriented programming. Implementation matters because it enables us to debug object-oriented programs and tune their performance.
The focus of our exploration of object-oriented programming is a translator from Java to C++. You design, implement, and evaluate your own translator as a term-long project, working in teams of four to five students. In fact, you build two versions of your translator, taking half a term for each version and presenting your work in class on completion of each version. To make the project manageable, your translator only translates a restricted subset of Java into an even more restricted subset of C++; though the second version covers more functionality than the first version. I also provide you with "helper" code, notably for parsing and pretty printing program source files.
Each group elects a speaker, who coordinates with the members of the group and with me. A new speaker is elected at the middle of the term.
Your group's midterm and final project presentations address three main issues:
You have a 12 minute slot for your presentation, which includes a demo of your translator and time to set up your laptop.
Every project group meets with the instructor every other week for an informal discussion of issues currently facing the group. Group members will probably need additional meetings amongst themselves to better coordinate their work.
All course-related announcements will be sent to the course mailing list. I encourage you to use this list to ask questions and discuss issues related to the course. If you have enrolled before the start of the term you are automatically subscribed to the list. Otherwise, use the above link to subscribe manually.
Group projects (50%), individual assignments (25%), final exam (25%).
Please review the departmental academic integrity policy. In this course, you may discuss assignments with other students, but the work you turn in must be your own. Do not copy another student's work. You must do the projects as a group but not with other groups and without consulting previous years' students, code, etc. You should help other students and groups on specific technical issues but you must acknowledge such interactions. Copying code or other work without giving appropriate acknowledgment is a serious offense with consequences ranging from no credit to potential expulsion.
This course relies on three different programming languages:
In more detail, the source language is
Java without nested classes, anonymous classes,
interfaces, enums, annotations, generics, the enhanced for
loop, varargs, and automatic boxing and
unboxing. Furthermore, the source language omits support
for synchronization, i.e., synchronized methods and
statements, and strict arithmetic operations, i.e. the
The target language is
C++ without virtual methods, inheritance, and, in
general, templates. It also omits features new to C++11,
notably lambda abstractions and type inference,
Most Java statements and expressions translate directly into the corresponding C++ statements and expressions (modulo minor language differences). As a result, the main challenges for the course project are figuring out (1) how to translate Java class hierarchies into C++ without inheritance and (2) how to implement Java's virtual method dispatch in C++ without virtual method dispatch, (3) how to select the right overloaded method, and (4) how to automatically manage memory without an existing garbage collector. Note that we will explore how to approach each challenge in class; we will also leave the latter two challenges for the second version of the translator.
Besides the programming language itself, any version of
Java includes a rather extensive set of platform
libraries, with the facilities in
Please note that the translator need not perform any correctness checks on source programs; in other words, you can assume that source programs are free of compile-time errors. At the same time, when writing your own Java test programs, it seems prudent to test them with a regular Java compiler.
Tools and Resources
For Java, we use the Java 2 Platform Standard Edition 5.0, née JDK 1.5, or later. Oracle provides an implementation for Linux. Apple provides an implementation with Mac OS X, no installation required. In either case, you need to separately install Java’s API documentation. In the case of Mac OS, the documentation is included with Xcode, Apple’s IDE.
For C++, we use gcc, the GNU Compiler Collection, as our compiler. It is the default compiler for Linux and included with Apple’s Xcode for Mac OS X.
If you are running Windows, please dual-boot into Linux or use a virtual machine monitor such as VirtualBox for running Linux. Trying to make gcc and make work on Windows (i.e., through a Unix emulation layer such as Cygwin) is not recommended.
Like many large-scale software projects, we rely on a version control system such as git to manage program sources and on make to automate the build management. If you are using github or a similar service, please make sure that your repository is not publicly visible.
To simplify the task of reading source files in one language, translating them into another language, and then printing source files for that language, we use the xtc toolkit for source-to-source translators. xtc includes a parser for Java source files, which converts the external, textual representation into an internal tree representation. It also includes support for traversing, modifying, and pretty-printing such trees.
You may also find the following resources useful: