2025-05-31 03:38:00
ratfactor.com
I think one of the most interesting questions in the Forth universe is
how small can its core be?
Which is to say, how few words do you need to
implement in a host language (or raw machine code, as we’ll see) before you can bootstrap
the rest of the language in the Forth itself?
(The most popular one I’ve seen is SUBLEQ, which stands for “SUBtract, branch
if Less than/EQual to zero”. And since there’s only one, you typically omit it
and your program is just the operands for the implied instruction. The
“language”, then, has no operations and feels to me like the computing
equivalent of John Cage’s musical stunt
4’33” (wikipedia.org).)
So I guess a Forth with one word is all you need.
Therefore, it’s not a question of, “How few words would be possible?” but
rather, “How few words would be interesting?”
The answer will be personal to you.
The Forth-eV Wiki’s page on “Minimal Word Set” is a great place to start:
In addition to the word set, you can also constrain the total file weight of your
core Forth. (Or lines of source or some other arbitary limitation.)
Some really intriguing minimal Forths I’ve encountered:
PlanckForth
I love the hexdump visualization of Koichi Nakamura’s PlanckForth:
You’re looking at a complete working Forth implementation in the form of a
hand-written ELF binary in less than 1,000 bytes. The rest of PlanckForth is
written in PlanckForth to implement a “normal” Forth.
SmithForth
David Smith’s SmithForth is another 1,000 byte, hand-written machine code Forth
that bootstraps a more complete Forth.
“My goal with SmithForth is not to stop writing machine code early, but to
start writing Forth early.”
sectorforth
Cesar Blum’s sectorforth is even smaller, at 512 bytes (the size of a boot sector).
Like other ultra-tiny Forths, it starts with just a handful of Forth primitives
with which to bootstrap higher-level constructs.
The included 01-helloworld.f
example is 200 lines of well-commented Forth
source which starts with making numbers, implements a core of standard
Forth words, and then prints “Hello world”.
I imagine this is how Ents talk.
“As soon as the whole company was assembled, standing in a wide
circle round Treebeard, a curious and unintelligible conversation
began.” –JRR Tolkein, The Two Towers
milliForth
512 bytes too much for you? How about 336? By my count, fuzzballcat’s
milliFORTH implements 11 words and it can do anything, just, you know,
painfully. The “Hello World” is 53 lines of pain.
StoneKnifeForth
Not just a hand-written Forth binary, but also a metacircular compiler,
Kragen Javier Sitaker’s StoneKnifeForth source comes to a total of 1,902
essential bytes.
“Surprisingly, the language that results is still almost bearable to write a
compiler in, although it definitely has the flavor of an assembler.”
Many Forths are also compilers and/or assemblers, but rare is the program that
can compile its own source in less than 2Kb.
“Three Instruction” Forth
Frank Sergeant’s 3-instruction Forth for an early 1990s Mototorla chip is
possibily the smallest of them all?
“How many instructions does it take to make a Forth for target development
work? Does memory grow on trees? Does the cost of the development system come
out of your own pocket? A 3- instruction Forth makes Forth affordable for
target systems with very limited memory. It can be brought up quickly on
strange new hardware. You don’t have to do without Forth because of memory or
time limitations. It only takes 66 bytes for the Motorola MC68HC11. Full
source is provided.”
How can you not want to learn about that? I mean, 66 bytes. What?!
“If you do have extra RAM available on the system then you can use the
3-instruction Forth to build and test a full Forth, and then use it.”
Keep your files stored safely and securely with the SanDisk 2TB Extreme Portable SSD. With over 69,505 ratings and an impressive 4.6 out of 5 stars, this product has been purchased over 8K+ times in the past month. At only $129.99, this Amazon’s Choice product is a must-have for secure file storage.
Help keep private content private with the included password protection featuring 256-bit AES hardware encryption. Order now for just $129.99 on Amazon!
Help Power Techcratic’s Future – Scan To Support
If Techcratic’s content and insights have helped you, consider giving back by supporting the platform with crypto. Every contribution makes a difference, whether it’s for high-quality content, server maintenance, or future updates. Techcratic is constantly evolving, and your support helps drive that progress.
As a solo operator who wears all the hats, creating content, managing the tech, and running the site, your support allows me to stay focused on delivering valuable resources. Your support keeps everything running smoothly and enables me to continue creating the content you love. I’m deeply grateful for your support, it truly means the world to me! Thank you!
BITCOIN bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge Scan the QR code with your crypto wallet app |
DOGECOIN D64GwvvYQxFXYyan3oQCrmWfidf6T3JpBA Scan the QR code with your crypto wallet app |
ETHEREUM 0xe9BC980DF3d985730dA827996B43E4A62CCBAA7a Scan the QR code with your crypto wallet app |
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.