Papers
Multi-stage Programming for Mainstream Languages (TR09-02)
echnical Report TR09-02, Department of Computer Science, Rice University
Multi-stage programming (MSP) constructs enable a disciplined approach to program generation. In the purely functional setting, it is possible to statically type-check MSP constructs to ensure that they can only generate well-typed programs. Despite numerous attempts, it has been difficult to extend this guarantee in the presence of key features of mainstream languages, especially imperative constructs.
This paper proposes a new method for achieving this guarantee and shows that it is powerful enough to express classic applications of MSP in Java. Our key insight is that safety can be regained by ensuring that the bodies of escapes are weakly separable from the rest of the code. This means that computational effects occurring inside an escape can only be visible outside the escape through types guaranteed to not contain code. Our method is simpler than prior proposals, and we expect that it can be intuitively understood by programmers. We formalize a calculus to demonstrate the soundness of the proposed approach. An implementation called Mint, which extends the Java OpenJDK compiler, is used to validate both the expressivity of the system and the performance gains attainable by using MSP in this setting.
- 5 Views
Nifty Assignment: Temperature Calculator
OOPSLA 2006 Educators Symposium
- 33 Views
Invariant Specification and Multi-Staging using Java Annotations
Poster
Java annotations allow programmers to attach metadata to programs. During normal execution, the annotations are ignored, but in contrast to comments in the source code, annotations can be manipulated programmatically at compile- or run-time. We propose two extensions -- subtyping and expression annotations -- for consideration in the Java specification request for annotations, and show how annotations can be used to express program invariants and multi-stage programs.
- 64 Views
Design Patterns for Parsing
SIGCSE 2005
We provide a systematic transformation of an LL(1) grammar to an object model that consists of
• an object structure representing the non-terminal symbols and their corresponding grammar production rules,
• a union of classes representing the terminal symbols (tokens).
We present a variant form of the visitor pattern and apply it to the above union of token classes to model a predictive recursive descent parser on the given grammar. Parsing a non-terminal is represented by a visitor to the tokens. For non-terminals that have more than one production rule, the corresponding visitors are chained together according to the chain of responsibility pattern in order to be processed correctly by a valid token. The abstract factory pattern, where each concrete factory corresponds to a non-terminal symbol, is used to manufacture appropriate parsing visitors.
Our object-oriented formulation for predictive recursive descent parsing eliminates the traditional construction of the predictive parsing table and yields a parser that is declarative and has minimal conditionals. It not only serves to teach standard techniques in parsing but also as a non-trivial exercise of object modeling for objects-first introductory courses.
- 17 Views
Nifty Assignment: Abstract Factories and the Shape Calculator
OOPSLA 2004 Educators Symposium
The Shape Calculator is an assignment targeted at CS1 students in an objects-first curriculum. It can serve as a powerful yet entertaining example of the advantages of object-orientation.
- 69 Views
ConcJUnit: Unit Testing for Concurrent Programs
7th International Conference on the Principles and Practice of Programming in Java (PPPJ 2009)
In test-driven development, tests are written for each program unit before the code is written, ensuring that the code has a comprehensive unit testing harness. Unfortunately, unit testing is much less effective for concurrent programs than for conventional sequential programs, partly because extant unit testing frameworks provide little help in addressing the challenges of testing concurrent code. In this paper, we present ConcJUnit, an extension of the popular unit testing framework JUnit that simplifies the task of writing tests for concurrent programs by handling uncaught exceptions and failed assertions in all threads, and by detecting child threads that were not forced to terminate before the main thread ends.
Practical Tools for Testing Concurrent Programs
Poster
In our experience with developing production programs in Java,
unit testing has proven effective in assuring the reliability of code with a single thread of control. Unfortunately, unit testing has proved much less effective in assuring the reliability of code with multiple threads of control, often simply because the JUnit testing framework silently ignores failures in auxiliary threads. Java libraries and user programs frequently make assumptions about the threading context in which they execute, but these assumptions are rarely enforced by the actual code and typically only appear in program documentation. Since thread scheduling is non-deterministic, a unit test can succeed on one run and fail on the next, or repeatedly succeed on one platform and occasionally fail on another.
To improve test-driven development for concurrent programs, we are developing
(i) an extension of the JUnit framework, actively supporting the developer by treating tests that could silently ignore failures in auxiliary threads as test errors;
(ii) a lightweight annotation language, which can be used to specify and check the threading properties of both existing and new code; and
(iii) a testing framework that can execute unit tests according to a specified set of recorded or generated schedules, elevating the unit testing of concurrent programs to a rigorous, deterministic process.
- 35 Views
Nifty Assignment: Marine Biology Simulation
OOPSLA 2004 Educators Symposium
The Marine Biology Simulation is designed as a final project in an objects-first CS2 course. It provides an entertaining setting that serves as compelling example of the powers of object-oriented design and programming.
- 42 Views
Design Patterns for Marine Biology Simulation
SIGCSE 2004
We specify and implement a GUI application that simulates marine biological systems by making extensive use of object-oriented design patterns.
The key design patterns are model-view-control, observer/observable, visitor, command, factory method and decorator. These design patterns help delineate the roles and responsibilities of the objects in the system, establish loose coupling between objects and arrange for the objects to communicate and cooperate with one another at the highest level of abstraction. The result is an application that exhibits minimal control flow, yet is powerful, robust, flexible and easy to maintain.
Our work entails a non-trivial redesign of the current AP Computer Science Marine Biology Simulation case study and may serve as a case study for an introductory “object-first” curriculum.
- 6 Views
A Framework for Testing Concurrent Programs
MS Thesis
Incremental, test-driven development is sweeping the software
industry, elevating testing from an ancillary activity to an integral part of the programming process. Unfortunately, in our recent experience developing production programs in Java, unit testing has only proven effective in assuring the reliability of code with a single thread of control; it is much less effective in concurrent programs.
To facilitate the development of concurrent programs, we are developing:
i) An extension of the JUnit framework that actively supports the developer by treating tests that could silently ignore failures in auxiliary threads as test errors;
ii) A lightweight Java annotation language that can be used to specify and check the threading invariants of both existing and new code;
iii) A testing framework that can record and analyze the schedules of unit tests, detect deadlocks, and run the tests using modified schedules, increasing the likelihood that concurrency problems are discovered.
- 16 Views
Assignments for an Objects-First Introductory Cumputer Science Curriculum
Designing an effective curriculum to teach programming and software engineering to beginning students is challenging. An objects-first course prepares students in an excellent way for the requirements in industry and academia by focusing on program design, thereby enabling students to write correct, robust, flexible, and extensible software. This paper outlines the effects of an object-oriented approach on software quality and describes five assignments that can be used as teaching tools in an objects-first course to evaluate and reinforce the students’ understanding.
- 5 Views


Like
Add Comment