67 lines
3.8 KiB
Markdown
67 lines
3.8 KiB
Markdown
# Luxferre's Truly Tiny BASIC (LTTB) implementations
|
||
|
||
## About
|
||
|
||
Luxferre's Truly Tiny BASIC (henceforth LTTB) is a lean dialect of the BASIC programming language, originally based upon the [Dennis Allison's design notes for Tiny BASIC](http://www.ittybittycomputers.com/IttyBitty/TinyBasic/DDJ1/Design.html) with some improvements inspired by [Tom Pittman's](http://www.ittybittycomputers.com/IttyBitty/TinyBasic/TBuserMan.htm) 6800 Tiny BASIC variant. Just like the original Tiny BASIC designs, LTTB aims for maximum portability and minimum implementation complexity.
|
||
|
||
## Specification
|
||
|
||
The LTTB specification expands upon the original Design Notes in the following manner:
|
||
|
||
- Line numbers from 1 to 32767 are supported.
|
||
- Any invalid statement (including `REM`) can be used for comments.
|
||
- No command can be abbreviated inside `IF` statements.
|
||
- `LET` and `THEN` keywords are optional.
|
||
- `IF` statements also allow inserting line numbers after `THEN`, making it possible to write self-modifying programs. In this case, `THEN` is mandatory.
|
||
- A special `RND(n)` function is introduced that generates a random number from 0 to `n-1`.
|
||
- The `NEW` command is synonym to `CLEAR`.
|
||
- The `BYE` command can be used to exit the interpreter.
|
||
- In the environments that support file systems or some kind of external file I/O, the `LOAD` command can be used to load BASIC programs into memory, and the `SAVE` command can be used to save BASIC programs from memory.
|
||
|
||
See the [manual](lttb-manual.md) for more details on every supported command and the [examples](examples/) directory for working examples.
|
||
|
||
If you want to create your own implementation of LTTB, see the [Implementation Notes](lttb-impl-notes.md) document for the details on the internal interpreter workings.
|
||
|
||
## Implementations
|
||
|
||
Here are all currently known implementations of LTTB:
|
||
|
||
* [Jim Tcl port](./lttb.tcl) (284 SLOC)
|
||
* [POSIX AWK port](./lttb.awk) (280 SLOC)
|
||
|
||
## Test suite
|
||
|
||
LTTB also ships a [test suite](test.bas) source code file to verify implementation correctness. Every non-empty line between the start and the end should end with `OK`.
|
||
|
||
## FAQ
|
||
|
||
Please read the [manual](lttb-manual.md) first, your question is most likely covered there. If not, here are some more questions and answers.
|
||
|
||
### Why make another Tiny BASIC clone in 2026?
|
||
|
||
Because it's a 1) great benchmark for any languages I'm currently mastering, 2) way to run vintage software and games, 3) nice practice for classic, hand-crafted coding.
|
||
|
||
Besides, the goal is not just to make one implementation and call it a day, but to port it to as many host languages and platforms as possible. I'd even say that eventually the implementations themselves may become more of a byproduct and the main value will reside in the design docs crystallized in the process.
|
||
|
||
### Which TB dialects is LTTB compatible with?
|
||
|
||
In general, you should be able to run anything compatible with:
|
||
|
||
* the original [Design Notes](http://www.ittybittycomputers.com/IttyBitty/TinyBasic/DDJ1/Design.html) by Dennis Allison;
|
||
* the original Tom Pittman's 6800TB (if the program doesn't have any `USR` calls and has proper spacing between the command and the rest of the statement);
|
||
* the [Damian Gareth Walker's implementation](http://tinybasic.cyningstan.org.uk/), provided all program lines are properly numbered (because that implementation uses auto–numbering when loading the programs).
|
||
|
||
### Will there be any TBX (Tiny BASIC Extended) or PATB (Palo Alto Tiny BASIC) compatibility?
|
||
|
||
No way.
|
||
|
||
### But are the existing implementations really tiny?
|
||
|
||
I think 300 SLOC of Jim Tcl for the entire interpreter (including the banner etc) is pretty tiny. Other implementations are also projected to be within this ballpark.
|
||
|
||
## Credits
|
||
|
||
Inspired by the great works of Dennis Allison and Tom Pittman.
|
||
|
||
All LTTB implementations in this repo were created by Luxferre in 2026 and released into the public domain with no warranties.
|