Concepts & Constructs

PhD Dissertation Cover

My PhD dissertation, titled Constructs & Concepts – Language Design for Flexibility and Reliability [pdf | bib] explored new language constructs and language designs, and is the basis for continuing work on the Magnolia Programming Language.

There’s a nice press release about it (in Norwegian).

Summary

Developing robust, reliable, flexible and maintainable software is challenging, especially with large projects. In this dissertation we look at language constructs and features to support the development of high-quality software through abstraction, specification and testing. We are particularly interested in the high-performance / numerical software domain. The work culminates in the design of the Magnolia programming language, intended to serve as a foundation for further research in this area.

Playing with Signatures

The same algorithm may often be realised in several different ways. For example, sorting can be seen as reordering a sequence, or as producing a new sorted sequence from an input sequence. The former maps naturally to an imperative procedure, while the latter maps naturally to how we would specify sorting in an algebraic specification. We introduce mutification and functionalisation, which allow us to map back and forth between imperative and algebraic code. In particular, algorithms may be implemented in an imperative style, which is often more efficient, especially in numerical software, but used – in both program specification and code – in the algebraic style. The algebraic style code can then be translated automatically to imperative style code.

Working with Concepts

Concepts define the operation interface of a set of types, and specifies the behaviour of operations with axioms. We show how axioms can be used for optimisation purposes by annotating them with axiom classes that describe how the should be used. Such optimisation is particularly useful on code written in an algebraic style, as this is the preferred style for writing axioms. We also discuss how to generate automated tests from concepts and axioms.

Axiom-Based Testing

We refine the idea of testing based on concepts and axioms, detailing how to generate tests in concept-enabled C++, and presenting a test generation tool for C++.

Handling Failure and Exceptions

Proper handling of failures and unexpected situations that arise is important in creating reliable software. We introduce alerts, which provide a unified approach to reporting and handling failure. In particular, alerts can enforce checking of return codes, and provide local or global handlers for different error situations.

Alerts can also associate errors with particular argument values, thus providing precondition checks integrated with the alert handling system. Improper checking of arguments is a significant source of bugs and security problems, so this is an important feature.

The Magnolia Programming Language

We discuss the design of the Magnolia language, which is designed around the ideas and features mentioned above. Magnolia is intended to provide a flexible basis for further language experiments, while providing enough control over the execution model to be useful for developing high-performance software.

Conclusion

The idea of mutification and functionalisation provides a crucial link between implementation and specification, and serves as an enabling technology for the work on testing and optimisation with concepts and axioms. We provide for increased reliability and robustness with axiom-based testing and the alert facility, while encouraging use of abstraction and an easy-to-reason-with algebraic style by providing axiom-based optimisation and reducing overhead with mutification.