Building A Programming Language From Its Core (with Peter Saxton)
Aug 7, 2024
auto_awesome
In this discussion with Peter Saxton, an expert in programming languages and abstract syntax trees (AST), listeners discover how the EYG language redefines programming. Peter explains the significance of focusing on ASTs rather than traditional syntax. He delves into balancing functional purity with practicality in EYG's design, explores type systems and row types, and highlights the ease of building interpreters with AST. The conversation also touches on innovative tools like Gleam for rapid prototyping, showcasing the dynamic future of programming languages.
The abstract syntax tree (AST) is essential for understanding a programming language's capabilities beyond mere syntax, shaping the core design principles of EYG.
EYG's robust type system and effect types transparently manage side effects, promoting reliable code and simplifying debugging for developers.
The language fosters a community-driven ecosystem, encouraging innovation through custom interpreters and DSLs, thus enhancing code sharing and reusability.
Deep dives
Understanding the Essence of Programming Languages
The core essence of a programming language extends beyond its syntax; it is fundamentally shaped by its features, library ecosystem, and community. In discussing this concept, emphasis is placed on the abstract syntax tree (AST) as a crucial element for understanding what a language can truly achieve. The AST represents the fundamental structure of a program once superficial syntax has been removed, highlighting the intrinsic capabilities of the language. This focus on the AST allows deeper exploration into language design and implementation, grounding discussions about programming languages in their true functional characteristics.
EYG: A New Language Built on Effects
EYG, or 'Eat Your Greens', is a modern functional programming language that emphasizes a robust type system while abstracting away the details of the underlying machine. Its design principles focus on allowing a clear separation of concerns, distancing operational details such as I/O and number representations from the language itself. As a result, EYG encourages developers to write more reliable code by establishing strong guarantees around side effects and type safety. This approach, which anticipates that designer decisions will lead to clearer code, facilitates a programming environment where complexity can be managed more effectively.
Effect Types and Their Benefits
EYG introduces effect types, which handle side effects in a transparent manner, thereby enhancing code reliability and maintainability. This feature allows developers to specify what side effects a piece of code may invoke, facilitating better understanding and debugging of programs. For instance, when a developer writes code that attempts to access the network, the type system can track and manage this effect, warning the developer of potential issues and making debugging simpler. Such mechanisms aim to provide a better programming experience by guiding developers in error prevention rather than merely offering post-factum corrections.
The Role of the Abstract Syntax Tree in EYG
EYG operates with a deliberately simplistic AST that serves as the backbone for its operation and language structure. This compact design allows the language to maintain its core functional characteristics while remaining extensible for future enhancements. The AST's simplicity means that it can easily accommodate various language features without introducing unnecessary complexity. Moreover, this approach positions the AST as a stable component upon which additional language functionalities can be built, fostering an ecosystem of tools and interfaces around the language.
Towards a Community and Ecosystem Around EYG
The vision for EYG includes fostering a community that contributes to a diverse ecosystem of languages and tools based on the concepts introduced by the language. By allowing developers to create their own interpreters and DSLs based on the AST, EYG aims to promote innovation in software design. Additionally, as the language matures, the goal is to facilitate a package ecosystem that enables code sharing and reusability among its users. This initiative could potentially lead to the emergence of unique applications in specialized fields, further establishing EYG as a flexible and valuable programming tool.
A language’s AST—it’s abstract syntax tree—is nearly always a hidden implementation detail. It’s not treated as part of the language, but merely the intermediate step between parsing and compiling. But this week’s guest aims to flip that relationship on its head...
Peter Saxton joins me to talk about EYG - an AST-first language that defines the fundamental capabilities first, and then stretches out from there to surface syntax and final execution.
The result is something that can teach us a lot about how a typed, functional programming language works; how an extensible effects system works; and could make writing a new programming language as easy as defining the syntax you want, and parsing that into EYG's AST.