Hippogriff: a semantic approach to uniting core and modules
This paper introduces Hippogriff, a language with a unified module system and dependent type theory that supports general recursion without compromising type-checking termination, and provides categorical semantics to justify this design by connecting dependent types with split-context type theories.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
In the world of computer programming, there is a long-standing divide between two ways of thinking about code. On one side, there is the practical, everyday work of writing instructions that tell a machine what to do, like adding numbers or moving data. On the other side, there is the abstract work of defining the rules and structures that govern those instructions, such as declaring what kinds of data are allowed. For decades, most programming languages have kept these two worlds strictly separate. They treat the rules as a rigid framework that exists only before the program runs, while the actual work happens only after. This separation keeps things simple and fast, but it forces programmers to write duplicate code: one version for the rules and another for the actions. It is like having to write a manual for a machine and then write the machine itself in two completely different languages, even though they describe the same thing.
Researchers have long sought a way to merge these two worlds, allowing the rules and the actions to exist in the same space. This would let programmers write more powerful, flexible code where the rules can change based on the data, and the data can influence the rules. However, this unification has historically come with a heavy price. To make the rules and actions mix safely, computers often have to stop and check every single step of a program before it runs, a process that can be incredibly slow or even impossible for complex tasks. Alternatively, some languages allow this mixing but force the programmer to give up powerful features like the ability to repeat actions indefinitely, which is essential for many real-world applications. The question remains: is it possible to have a language where the rules and actions are unified, yet the computer can still check the code quickly and allow for powerful, repeating operations?
A team of researchers at the University of Oxford has built a new programming language called Hippogriff that answers this question with a resounding yes. They have created a system that successfully unites the core instructions of a program with its modular structure, allowing for a level of flexibility previously thought incompatible with fast, reliable checking. The key to their success is a clever mathematical trick that treats the moment of checking as a distinct state from the moment of running, without forcing the programmer to write in two different languages. By using a concept they call a "synthetic phase distinction," the researchers designed a language where the computer can look at the code and understand its structure instantly, even while allowing for complex, recursive operations that would usually cause a system to crash or stall.
The researchers did not just propose a theory; they built a working implementation of Hippogriff to prove it works. In this new language, a programmer can define a type of data, such as a list of numbers, and then immediately use that definition to create functions that operate on it, all within the same block of code. The language handles the complexity of these definitions automatically. For instance, a programmer can write a function that calls itself repeatedly to process a list, a feature known as recursion, which is often difficult to combine with strict type checking. In Hippogriff, this is allowed because the system is designed to ignore certain details during the checking phase that do not affect the overall structure, effectively skipping over the parts of the code that would normally cause a delay.
This approach stands in contrast to other modern languages that have tried to solve similar problems. Some languages, like those used in advanced mathematical proofs, allow for this kind of unification but require the computer to evaluate every single step of the program during the checking phase. This forces the programmer to ensure that every loop and function eventually stops, which limits what the language can do. Other languages, like those used in standard software development, keep the rules and actions separate to ensure speed, but this forces the programmer to repeat themselves and limits how dynamic the code can be. Hippogriff finds a middle ground by separating the logic of the check from the execution of the code. It allows the computer to verify the structure of the program without needing to run the potentially infinite loops that might exist inside it.
The implementation of Hippogriff relies on a specific design choice where the language treats types as values. This means that a type, which is usually just a label for a kind of data, can be passed around and manipulated just like a number or a word. This might sound like it would make the system chaotic, but the researchers built a safety mechanism into the core of the language. They ensured that when the computer checks if two pieces of code are equal, it only looks at the parts that matter for the structure, ignoring the specific values that might be changing or looping. This allows the system to remain fast and predictable. If a programmer tries to write code that would cause the computer to get stuck in an endless loop while checking, the language simply treats that part of the code as a placeholder during the check, allowing the verification to finish quickly.
One of the most significant findings of the paper is that this approach does not require the computer to be a super-intelligent oracle that can predict the future of a program. Instead, it uses a method where the computer checks the code in a way that is similar to how a human might read a blueprint. The human looks at the overall structure to see if the rooms are connected correctly, without needing to walk through every single door to see if it opens. Similarly, Hippogriff checks the connections between the different parts of the program without needing to execute the code inside those parts. This allows the language to support features like "dependent types," where the type of data depends on the value of a variable, a feature that has been difficult to implement in practical programming languages.
The researchers also demonstrated that their language can handle complex module systems, which are ways of organizing code into reusable blocks. In many languages, creating a module that can adapt to different types of data requires a lot of boilerplate code and strict rules. In Hippogriff, these modules can be defined with the same syntax used for simple functions, making the code much more concise and easier to read. The system automatically handles the complexity of ensuring that the modules fit together correctly, even when they are nested inside one another or when they refer to themselves. This level of integration was previously only possible in languages that sacrificed either speed or the ability to write complex, recursive code.
The paper also addresses the issue of how the language handles errors. Because the system is designed to check the structure of the code without running it, it can provide clear and immediate feedback to the programmer if something is wrong. If a programmer makes a mistake in the structure of a type, the error message explains exactly where the problem is in terms of the code they wrote, rather than in terms of a complex internal translation that the programmer never saw. This makes the language much more user-friendly for developers who want to use advanced features without needing to be experts in the underlying theory.
The work presented in this paper is not just a theoretical exercise; it is a practical demonstration that the barriers between different ways of programming can be broken down. The researchers have shown that it is possible to have a language that is both powerful and safe, combining the best features of different programming paradigms. By using a synthetic phase distinction, they have created a system where the computer can understand the intent of the code without getting bogged down in the details of its execution. This opens the door for a new generation of programming languages that are more expressive and easier to use, allowing developers to write code that is both flexible and reliable.
The success of Hippogriff suggests that the future of programming languages may lie in this kind of semantic unification. Instead of forcing programmers to choose between different styles of coding, languages can evolve to support a single, unified approach that handles all the complexities automatically. The researchers have provided a blueprint for how this can be done, showing that the mathematical foundations are solid and the implementation is feasible. While there is still work to be done to refine the language and make it even more ergonomic for everyday use, the core idea has been proven to work. The result is a language that feels natural to write, even as it performs complex checks behind the scenes, bridging the gap between the abstract world of types and the concrete world of values.
In the end, the paper presents a significant step forward in the field of programming language design. It challenges the long-held belief that certain features must be mutually exclusive and shows that with the right mathematical tools, they can coexist. The researchers have built a language that is not only theoretically sound but also practically implementable, offering a glimpse into a future where programming is more intuitive and powerful. The work of Hippogriff demonstrates that by rethinking the fundamental assumptions about how code is checked and run, we can create systems that are better suited to the complex needs of modern software development. The path forward is clear, and the potential for innovation in this area is vast.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.