not-abc is a tiny self-hosting compiler developed for a high-performance computing course at Ulm University. It is deliberately small enough for students to understand the complete path from source code to generated code, while supporting functions, variables, pointers, control flow, recursion, and dynamic memory. It can compile its own source code, making self-hosting tangible.
not-abc is a minimalistic, self-hosting programming language and compiler designed for educational purposes, showcasing the principles of compiler construction using a compact language framework. With only 64-bit values, no static type checking, and a handful of built-in functions, this project exemplifies how a small language can successfully implement a complete compiler, affirming that simplicity can achieve complexity.
Minimal Language Design: not-abc operates with global variables and functions, supporting essential features such as local and global variables, arithmetic, comparison, and logical operators, as well as control structures like while loops and if statements.
Self-Hosting Compiler: The entire compiler is written in not-abc, emphasizing the self-hosting capability. It reads source code from standard input and writes LLVM IR to standard output, enabling seamless transitions from high-level programming to compiler design.
Dynamic Memory Management: The language incorporates critical functions such as malloc() and free(), allowing for dynamic memory allocation, essential for building robust data structures.
A simple "Hello, World!" program in not-abc:
fn print(s) {
while (#s) {
putchar(#s);
s = s + 1;
}
}
fn println(s) {
print(s);
putchar('\n');
}
fn main() {
println("hello, world!");
}
The development of not-abc is closely tied to an undergraduate course on High Performance Computing. This course facilitates hands-on learning, where students progress from building hardware components (e.g., NAND gates, logic gates, processors) to developing a comprehensive compiler. The culmination of the course enables students to generate code for custom processors, bridging their hardware knowledge with software implementation.
Currently, English-translated teaching materials, including worksheets and lecture notes from the course, are being developed. The resources are structured into 26 sessions, encompassing foundational topics that progressively build towards the development of the not-abc compiler.
Through its educational framework, not-abc offers a unique approach to understanding compiler construction and computer architecture. It illustrates how effective learning methodologies can simplify complex concepts, providing a solid foundation for future programming endeavors.
No comments yet.
Sign in to be the first to comment.