Wow, ZLisp is a LISP interpreter consisting of approximately 300 lines of code, written in the Zig programming language.
This is because LISP has an extremely concise syntax while also offering very flexible and powerful expressive capabilities.
I previously implemented a LISP interpreter in the C language. Now, I want to learn the Zig language and take the opportunity to compare the characteristics of the two languages. My conclusion is that Zig is a better alternative to C.
- Parsed the basic syntax of LISP language
- Implemented 4 LISP primitives, including addition, subtraction, multiplication, and division
-
Support for more syntax, including strings, annotations, and references
-
Support for more LISP primitives, including
append, begin, car, cdr, cons, =, length, list, not, print, define, setq, repeat, load, eval
- Sign into GitHub
- Fork the project repository
- Clone your fork
- Navigate to your local repository and code or fix
- Run passed $zig build test
- Make your Pull Request
I adhere to the philosophy of a straightforward implementation without any unnecessary techniques.
- 897k with zig build
- 90K with zig build -Doptimize=ReleaseSmall
Peter Norvig's LISP implementation in Python: https://www.norvig.com/lispy.html