Werner Dietl
wdietl@uwaterloo.ca, Room EIT 4007
Precise Inference of Expressive Units of Measurement Types
“Precise Inference of Expressive Units of Measurement Types” by T. Xiang, J.Y. Luo, and W. Dietl. Object-Oriented Programming Systems, Languages, and Applications (OOPSLA), 2020, pp. 1-28.
Abstract
Ensuring computations are unit-wise consistent is an important task in software development. Numeric computations are usually performed with primitive types instead of abstract data types, which results in very weak static guarantees about correct usage and conversion of units. This paper presents PUnits, a pluggable type system for expressive units of measurement types and a precise, whole-program inference approach for these types. PUnits can be used in three modes: (1) modularly check the correctness of a program, (2) ensure a possible unit typing exists, and (3) annotate a program with units. Annotation mode allows human inspection and is essential since having a valid typing does not guarantee that the inferred specification expresses design intent. PUnits is the first units type system with this capability. Compared to prior work, PUnits strikes a novel balance between expressiveness, inference complexity, and annotation effort. We implement PUnits for Java and evaluate it by specifying the correct usage of frequently used JDK methods. We analyze 234k lines of code from eight open-source scientific computing projects with PUnits. We compare PUnits against an encapsulation-based units API (the javax.measure package) and discovered unit errors that the API failed to find. PUnits infers 90 scientific units for five of the projects and generates well-specified applications. The experiments show that PUnits is an effective, sound, and scalable alternative to using encapsulation-based units APIs, enabling Java developers to reap the performance benefits of using primitive types instead of abstract data types for unit-wise consistent scientific computations.
BibTeX entry:
@article{XiangLD20, author = {T. Xiang and J.Y. Luo and W. Dietl}, title = {{Precise Inference of Expressive Units of Measurement Types}}, journal = {Object-Oriented Programming Systems, Languages, and Applications (OOPSLA)}, }
Copyright notice: This material is presented to ensure timely dissemination of scholarly and technical work. Copyright and all rights therein are retained by authors or by other copyright holders. All persons copying this information are expected to adhere to the terms and constraints invoked by each author’s copyright. In most cases, these works may not be reposted without the explicit permission of the copyright holder.
(This webpage was created with bibtex2web.)