delvingbitcoin
Debuggable Lisp Scripts
Posted on: October 29, 2024 12:14 UTC
The focus has been on addressing the feedback about the challenges of writing btclisp code, specifically the translation of high-level Lisp to low-level code for effective debugging and interpretation.
This reflection led to an exploration of racket-lang as a potential solution due to its design for creating domain-specific languages (DSLs), integrated development environment (IDE), and introductory computer science tools. However, difficulties persist, particularly when macros are involved, complicating debugging processes and requiring significant customization for debugging interfaces. Furthermore, the lack of readily available libraries for cryptographic operations posed additional challenges in implementing transaction parsing and secp mathematics.
Macros, while beneficial for language development by allowing expressions to perform complex operations implicitly, introduce confusion during debugging by not representing the code directly written by the developer. This disconnect undermines their utility in practice, despite their theoretical appeal for building language features. Additionally, the dilemma of incorporating an "eval" function within a language raises questions about translating high-level instructions into low-level code effectively. This issue highlights the inherent conflict between maintaining a high-level evaluation function and ensuring accurate translation to low-level implementation.
The consideration of miniscript offered a promising direction by treating the high-level language as a variation of the low-level language, suggesting the use of dual interpreters alongside a separate translator/compiler. This approach, though introducing potential discrepancies between high-level and compiled outputs, presents a worthwhile tradeoff by potentially enabling formal analysis tools to resolve such differences.
Subsequent developments led to the creation of a basic Lisp language termed "bll," aimed at integrating into consensus mechanisms, and "symbll" (symbolic bll) for higher-level programming with straightforward compilation into bll. A REPL environment, "bllsh" (bll shell), was developed for these languages, facilitating debugging through both print statements and step-through debugging features. The compiler's logic relies on simple macro rewriting, offering room for future optimization but already demonstrating effectiveness in running and debugging high-level code natively.
This evolution reflects a significant shift in language design, moving towards a model that balances ease of programming with the complexity of debugging and translating between high and low-level code representations. The project, including its pun-intended naming convention, marks a new phase in scripting language development, aiming for improved usability and debugging capabilities. The GitHub repository for bllsh can be found at https://github.com/ajtowns/bllsh, showcasing the practical application and ongoing evolution of this programming language initiative.