Sure, gForth still doesn't have a decent way to make HTTP requests or match a regular expression, but writing libraries like that doesn't seem to be fun for the average FORTH developer, who would rather reimplement a very barebones language environment to address the gap left by the other 1200 FORTHs.
It's not that these projects aren't cool, but if you actually want the language to become popular why not look at things every other popular language has?
That’s something you could prevent with an advanced compiler that inlines lots of code and carefully tries to put functions often called together in cache lines, but this code doesn’t do that, and if you did, why spend that effort on your compiler if a simple traditional language makes that inlining easier?
The problem is that every program is a DSL, so it’s hard to grep unless you built it. It’s a great personal hacking language though.
I often wonder, though, because of the mechanics of context with LLMs, if forth might not be the ideal language for LLMs to write simple tools for their own use?
Could we pawn off the “you should try forth” problem onto AI lol?
So in my opinion this is somewhat antithetical to the idea of FORTH
> 100% C/C++ with multi-platform support. Though classic implementation of primitives in assembly language and scripted high-level words gave the power to Forth, it also became the hurtle for newbies. Because they have to learn the assembly and Forth syntax before peeking into the internal beauty of Forth.
Fair enough to write a core of FORTH in C as a kind of portable assembler but most of the system should be written in FORTH in my opinion, then you can change it from FORTH. As fast as I can see eForth is written entirely in C.
Anyway FORTH is fun, writing your own is fun too and a great educational experience, but despite being a fan, I wouldn't write anything serious in it today. It is much too low level and it has even less memory safety than C!
The elegance of it continues to impress though with functional programming to get the job done and compile time programming to mold the language into that DSL which expresses the problem perfectly.
Tethered Forth programming on small devices is an underrated opportunity, IMO. There is also the opportunity to revise the OpenBoot project, I remember the days of automation for deployments at the Bios, it was an amazing tool for massive deployments of Sun T systems in telcos.
It has always fascinates me how Forth has been historically used for low level embedded programming, but also can be as high level as you’d like. I feel like this isn’t a concept that has really gone away.
- optimizing the code density (threaded interpretation)
- the dynamicism was said to allow for numerical optimization not possible in math libs / fortran long ago
(see J.V.Noble papers, I'm not knowledgeable enough to confirm his claims but i assume they hold some ground)
- the bare-metal repl feel is also special, as freeing as poking basic on old hardware but with the freedom of lisp in a way
forth sits in the thinking-altering languages land firmly imhoIMO Forth is easiest language to implement from scratch, especially on stack based CPUs :)
An interesting project chose it as its lang: https://collapseos.org/
Phew - that is a terse language. I have heard it compared to assembly language and yeah I see that.
Oh, please. I've written in Forth. It's useful when you have to do a cram job to fit in a really tiny machine. Otherwise, no.
Prove that. Record some videos, show me some code and metrics that'll be evidence that I'm getting 10x more productive.
Look at the languages in the repository:
C 50.6%
C++ 47.6%
Forth 1.5% <-----
HTML 0.1%
Makefile 0.1%
JavaScript 0.1%
How does that build credibility?
FORTH has been used to control deep space telescopes and planetariums --it's a great way to expose instrumentation for high-level access, but that access might not be human anymore, it could just as easily expose instrumentation to AI agents.
For example, a FORTH page could contain a prompt "Animate a galloping black and white zebra on the attached 64x32 RGB LED matrix, cache the code to do this on a FORTH page called ZEBRASHOW6432." Another could prompt "Run ZEBRASHOW6432 at the top of the hour during weekdays in the Pacific Time Zone." This might involve lifting C drivers from Arduino and CircuitPython for the 64x32 RGB LED matrix driver into FORTH (trivial) and building an MCP-to-FORTH server, but endless fun...
So I guess it's best to stop reading about FORTH and grab an rP0-2W and attach desired indicators, sensors, actuators and transceivers to see for yourself.
Thought for 1m 0s
Yes, it's possible to implement a Forth interpreter or compiler using a macro processor like M4 (and by extension, its evolutionary successor M5, which shares similar macro expansion and substitution principles). Macro processors excel at text transformation, making them ideal for generating low-level code (e.g., assembly) from high-level Forth definitions. While no public implementation specifically uses Alan Dain Samples' historical M5 (whose source and detailed examples are scarce), a robust example exists using GNU M4 to create a Forth-to-Z80 assembler cross-compiler. This targets the ZX Spectrum but demonstrates the technique: M4 macros define Forth primitives (e.g., stack ops, arithmetic) as Z80 instruction snippets, handling control flow with label counters for uniqueness.M5, as an M4 evolution, would adapt similarly—its enhanced features (e.g., better argument handling and streams) could streamline expansions, but the core approach (defining words as macro substitutions) translates directly. Below, I'll outline how it works, provide key macro definitions, and show a complete example. This generates human-readable, annotated assembly without peephole optimization but with inline efficiencies (e.g., DUP ADD → _2MUL).How It WorksCore Mechanism: Input Forth code (e.g., : FOO DUP ADD ;) is processed by M4. Macros like DUP expand to Z80 code preserving stack effects (data stack in HL/DE/SP; return stack in HL'/DE'/BC'). Labels use counters (e.g., if100) to avoid conflicts.
Stacks: 16-bit data stack; return address stack (RAS) for loops/recursion.
Compilation: m4 input.m4 > output.asm, then assemble (e.g., with Pasmo for Z80).
Adaptation to M5: Use M5's = for definitions (vs. M4's define) and => streams for output diversion. Argument parsing aligns closely.
Limitations: Uppercase words only; 16/32-bit ints; basic floats via ROM.
Key Macro DefinitionsMacros are modular (e.g., in stack.m4, arithmetic.m4). Here's a selection:Stack Manipulation (e.g., from stack.m4):
define({DUP},{ ; ( x1 -- x1 x1 )
ex DE, HL ; 1:4 dup
push HL ; 1:11 dup})dnl
define({SWAP},{ ; ( x2 x1 -- x1 x2 )
ex DE, HL ; 1:4 swap})dnl
define({DROP},{ ; ( x1 -- )
pop HL ; 1:10 drop
ex DE, HL ; 1:4 drop})dnl
define({PUSH($1)},{ ; ( -- n )
push HL ; 1:11 push($1)
ld HL, $1 ; 3:10 push($1)
ex DE, HL ; 1:4 push($1)})dnl
Optimization Example: DUP DUP → DUP_DUP for fewer instructions: define({DUP_DUP},{ ; ( x1 -- x1 x1 x1 )
exx ; 1:4 dup dup
push HL ; 1:11 dup dup
exx ; 1:4 dup dup
ex DE, HL ; 1:4 dup dup
push HL ; 1:11 dup dup})dnl
Arithmetic (e.g., from arithmetic.m4): define({ADD},{ ; ( x2 x1 -- x )
add HL, DE ; 1:11 +
ex DE, HL ; 1:4 +
pop HL ; 1:10 +})dnl
define({SUB},{ ; ( x2 x1 -- x )
or A ; 1:4 -
sbc HL, DE ; 2:15 -
ex DE, HL ; 1:4 -
pop HL ; 1:10 -})dnl
define({MUL},{ ; ( x2 x1 -- x ) [Binary long multiplication loop]
push BC ; 1:11 *
ld B, H ; 1:4 *
ld C, L ; 1:4 *
ld HL, 0x0000 ; 3:10 *
ld A, 0x10 ; 2:7 *
mul_loop101: ; *
add HL, HL ; 1:11 *
rl E ; 2:8 *
-- ETC ETC. Rest of assembly pørn censored.