As one of the oldest programming languages still in common use today, and essential for the first wave of Artificial Intelligence research during the 1950s and 60s, Lisp is often the focus of interpreters that can run on very low-powered systems. Such is the case with [Robert van Engelen]’s TinyLisp, which only takes 99 lines of C code and happily runs on the Z80-based Sharp PC-G850V(S) pocket computer with its 2.3 kB of internal RAM and native C support.
The full details on how TinyLisp was implemented and how to write it yourself can be found in the detailed article that’s part of the GitHub project. It supports static scoping, double-precision floating point and features 21 Lisp primitives along with a garbage collector. Two versions for the Sharp PC-G850 (using BCD (i.e. NaN) boxing) are provided, along with a number of generic implementations, using either double or single precision floating point types. A heavily commented version is probably the version to keep alongside the article while reading.
TinyLisp is – as the name implies – very tiny, and thus more full-featured Lisp implementations are widely available. This includes two versions – linked at the bottom of the Readme – also by [Robert] that use a gargantuan 1,000 lines of C, providing a more advanced garbage collector and dozens more Lisp primitives to handle things like exceptions, file loading, strings and debug features.
They’re 99 horrid, terrible lines, no one would ever write. Simply atrocious to read. If the author got rid of the useless preprocessor macros and formatted the code, it would help heaps, but it wouldn’t be the arbitrary cool factor of 99 lines anymore.
Mind you, the entire point is the 99 line claim, as that’s both what the article was written for, and what the project README points out immediately. It’s not about the interpreter. It’s the line count.
It’s fun, like solving a Sudoku puzzle. It’s not meant to be well maintained production quality code.
Although let’s be real, most code in production just gets thrown out and replaced when the requirements change, the staff changes, or a hot new language catches the eyes of the project architect.
I’d like to see a lisp/scheme that is kind of like that C in Four Functions project (https://github.com/rswier/c4 ). While I found C4 to be somewhat readable and informative, there are some serious compromises because the source was designed to be compiled by itself. So you kind of see data structures written in a way that would suit a 1980’s assembler program rather than a 21st century C program. (it’s more about function count instead of line count, it’s much bigger than TinyLisp)
For LISP macros were a big deal, bigger than for C. That’s not preprocessor, it’s part of language with appropriate facilities. Perhaps some modern implementations do it that way, but there it wasn’t the case.
An excellent introduction to Lisp with a practical, portable interpreter small enough to be implemented for any ‘C’ compiler with pretty much any target and small enough to be converted directly into assembly language for a small (even embedded). It gives a strong flavour of early Lisp; packaging all the concepts into an easily digestible form.
Looking at the code, yeah if you do a bunch of one liners and don’t have any blank lines or comments then anything can be 99 lines
This always irked me as a measure intended to impress. In some languages everything could be just a one liner..basic, C to some extent, JavaScript absolutely
I’m more impressed by statement count.
I have not looked at Lisp in years. He has a nice intro at https://github.com/Robert-van-Engelen/tinylisp/blob/main/tinylisp.pdf
For what it’s worth, that PDF is also linked in the article (which, to be fair, might have been edited after you made your comment) – “…how to write it yourself can be found in the detailed article that’s part of the GitHub project”.
“…As one of the oldest programming languages still in common use/b>< today…”
By whom; where?
Do not make statements such as this without providing verifiable data. (such statements, but regarding Cobol and Fortran, are easily backed up by good, solid facts…)
Attribution(s) (and facts) will follow, won’t they. (?) …
“…and essential for the first wave of Artificial Intelligence research during the 1950s and 60s…”
A slight re-work of that famous quotation by Garrison Keillor, and one which provides the perfect description of Lisp’s adherents / admirers, and the utility of Lisp, follows; to wit:
“Anyone who thinks sitting in church can make you a Christian must also think that sitting in a garage can make you a car.”—Garrison Keillor
…simply change a few words, and you have the perfect description of Lisp and its fan-base…
“Anyone who thinks that learning and using Lisp can make you an ‘artificial intelligence’ [whatever THAT is] expert must also think that sitting in a garage can make you a car.”
If you must spend your time learning another language, spend it on one which is much more intellectually satisfying and infinitely more productive: learn Forth. Learn Ada.
i love forth, and i love lisp. they have some attributes in common, and some that are quite different. i am glad i’ve learned each. i don’t understand hatred for lisp.
a fairly famous lisp evangelist once told me that he thought he had learned everything about forth by writing a “forth with parentheses” in lisp, and that made me angry. but the language itself is fine. and that guy’s work is pretty good too :)
LISP, well modern versions with objects and generics, are very employed in CADs, data processing, 3d design, and well, AL design (artificial life, erroneously called AI in games). Clojure is also a dialect of LISP, LISP++ if you may
Lisp is not the language, but the architecture. You can do any language in about 99 lines of Lisp. Problem is that linked-list architecture was best in restricted address space with fixed-width commands.
— We might have renaissance at some time if we accept that smallest data bit aka Lisp-node is 100 bytes long and Lisp-machine is the whole universe.