Teeny Scheme
Where TinyScheme is a word, Teeny Scheme is a jargonism. Short, modern, snappy, likely to be forgotten and abandoned real soon. Probably Smells Like Teen Spirit.
Teeny Scheme [repository] is a fork of TinyScheme maintaining the original’s focus on smallness. But with some more values added on top: readability and strictness. The code should be readable and easily modifiable. In part because it should scream at you if something goes wrong.
Teeny tries to be at least R5RS compliant, and it kinda is, given the default init. Given an R5RS-compatible init, R7RS-like Scheme can be bootstrapped using teenylib. However, there are significant problems and incompatibilities with R5RS and R7RS compliance that are unlikely to get fixed. Use with caution.
Getting Started
Teeny Scheme has really low requirements:
- A C99+ compiler (Teeny currently builds successfully on GCC, Clang, TCC, ChibiCC, and slimcc with respective CLI flags set in makefile)
- C++ compiler might be used for testing and type-hardening, but successful build and use is not guaranteed.
- POSIX Make (plus optionally
+=assignment supported by GNU Make, BSD Make, and pdpmake) - (Optional) POSIX ed(1) to build init.h.
- (Optional) math library (
math.h/libm.so) - (Optional) dynamic loading library (
dlfcn.h/libdl.so) - (Optional) utf8proc library for Unicode / UTF-8 support. While it might seem alluring to implement Unicode support oneself, it is a whole project in itself that’d essentially duplicate the effort of existing library. Integrating an established and reliable library like utf8proc is a better choice.
What’s left is cloning and building it:
$ git clone https://codeberg.org/aartaka/teenyscheme $ cd teenyscheme $ make all $ ./teenyscheme -h Usage: ./teenyscheme -h ./teenyscheme ./teenyscheme [<file1> <file2> ...] ./teenyscheme [<file1> <file2> ...] -1 <file> [<arg1> <arg2> ...] ./teenyscheme [<file1> <file2> ...] -c <expr> [<arg1> <arg2> ...] Use - as filename for stdin. $ sudo make install $ teenyscheme
You don’t really need Make, in fact. You only need to build scheme.c and optionally dynload.c. It’s all of the interpreter in a single file. Well, there are headers, but these are inlined at build time, so who cares. One final executable. Valuable, I believe.
Teeny Scheme Values
- Smallness
- If scheme.c grows beyond 10KLoC, this project has failed. Optimal size hovers around 6-7KLoC and I’ll try to preserve that. In case something can be implemented on the Scheme side (likely in teenylib,) it has to.
- Readability
- A lot of syntactic sugar and… interesting stylistic choices are made. See CONTRIBUTING.md for the explanation of these.
- Strictness
- Compiler should enforce as much as possible.
So: strict types (booleans, width-restricted integers,
_Nonnull,nullptr,size_t) and a lot of compiler flags to check suspicious behaviors. - Configurability / optionality
- Most features should be disableable, either at compile-time or launch-time. See config.h for a list of macros determining behaviors.
- Zero slop policy
- This is a project created in part as a response to many small Schemes succumbing to Generative AI. This small Scheme will have zero slop, I can promise you that. There’s an official policy in place for that too.
There’s a number of non-values too:
- C89 compatibility
- C89 is dated and un-ergonomic. If you want C89, use the original TinyScheme.
- Performance
- Teeny Scheme is likely to stay slow forever, with only marginal performance wins.
Due to codebase size cap, smarter compilation or whatever is unlikely.
The best we have is
-O3. - Preservation of the original TinyScheme code.
- It is only preserved in spirit. Huge refactoring has already been done, so it might look real different from the original. In a good way, supposedly.
- Preservation of TinyScheme API
- This is low priority and I’m likely to break API occasionally. Bug reports welcome!
- Full R7RS compliance
- See the standard compliance section in the manual for a listing of features that won’t be supported (full numerical tower and TCO, for example.)
Documentation
See the manual.
Acknowledgements
Teeny Scheme is a fork of TinyScheme R7. TinyScheme R7 is a fork of classic TinyScheme. And TinyScheme itself is a fork of MiniScheme. Which means: a lot of work has gone into making this project work. I do not claim any credit for it and I’m grateful to the people that I took this code from. Please respect their work. See the AUTHORS file.
License
Teeny is distributed under the terms of BSD 2-clause license.