Autology, a new functional interpreted Lisp language written in Clojure, has sparked a lively discussion among programming language enthusiasts. The project's distinctive feature is that it provides programs with access to their own interpreter at runtime, allowing for dynamic modification of the language's behavior during execution.
Runtime Language Modification
Autology takes an unusual approach to metaprogramming by binding its interpreter function to a variable called **
that's accessible within the program itself. This design allows developers to modify how the language evaluates expressions while the program is running. Unlike traditional Lisp macros that operate at compile time, Autology enables complete runtime rewriting of language syntax and semantics.
The creator of the project, who goes by Kimbsy, describes it as mainly for fun and to explore a neat idea, acknowledging that the current implementation is very slow and resource intensive. Kimbsy is scheduled to present talks about Autology at London Clojurians in May and Lambda Days in Krakow in June.
Key Features of Autology
- Written in Clojure
- Interpreter function is available as a data structure to the program
- Bound to the variable
**
in the execution environment - Allows modification of language behavior at runtime
- Can add, modify, or remove language features dynamically
Related Projects and Concepts
- Common Lisp implementations (SBCL, CCL) with interpreter access packages
- Reader Macros in Common Lisp
- FEXPRs (historical Lisp feature)
- Kernel programming language by John Shutt
- "Towers of interpreters" research by Amin & Rompf
- Shen language
Comparison to Traditional Lisp Approaches
The community discussion reveals interesting comparisons between Autology and traditional Lisp implementations. Several commenters noted that Common Lisp implementations like SBCL (Steel Bank Common Lisp) and CCL (Clozure Common Lisp) already provide packages for interacting with interpreter internals, though not in the same direct manner as Autology.
One commenter explained how Common Lisp's reader macros can achieve similar flexibility:
You can actually get completely stupid with this in Common Lisp using something called a Reader Macro which lets you temporarily take complete control over the interpreter.
The discussion also touched on historical Lisp concepts like FEXPRs (Function Expressions), which were early attempts at providing similar capabilities but were eventually abandoned in favor of macros for performance reasons. A detailed technical explanation by user kazinator highlighted how Autology's approach differs from FEXPRs by passing a customizable interpreter object rather than just a lexical environment.
Theoretical Applications and Limitations
While primarily created as an experimental project, the community discussion explored potential applications for such extreme runtime flexibility. One theoretical use case mentioned was the ability to switch between different language syntaxes within lexical scopes, allowing developers to express different parts of a complex problem in the language best suited for each part.
The project includes examples of inter-lingual code that demonstrates switching between different language syntaxes within the same program. Some users suggested this could potentially serve as an improved Foreign Function Interface (FFI) mechanism, though others questioned whether the benefits would outweigh the complexity costs.
Several commenters drew connections to related work, including John Shutt's Kernel programming language, Nada Amin and Tiark Rompf's research on towers of interpreters, and the Shen language. These connections highlight Autology's place within a broader exploration of language extensibility and reflection in programming language design.
Despite its current limitations as a practical tool, Autology demonstrates the creative possibilities that emerge when programming languages are designed with extreme flexibility in mind. As one commenter noted, it's impressive how many ideas can be explored with just 1,000 lines of Clojure code.
For those interested in exploring Autology further, the project is available online, with examples demonstrating how to add functions to the language, switch evaluation strategies, or even define a metacircular Lisp inside the program.
Reference: Autology