phreda4 has been doing cool stuff with ColorForth-likes for ages and for some reason barely gets any attention for it. Always brings a smile to my face to see it submitted here
Inspired by this article, I tried to read some tutorials on Forth. My question is whether concatenative languages are AI-coding friendly. Apart from the training data availability, the question is also whether LLMs can correctly understand long flows of concatenated operations. Any ideas?
Not relevant for modern LLMs, but concatenative, stack-based languages are very good at genetic programming applications. Concatenation tends to yield more viable programs when things are being mutated over time.
Don't use AI, it writes Forth like it writes C. It has got better at following Standard, in Gforth style, but it is awful at the spirit of Forth: factoring programs into a vocabulary of tiny, reusable pieces.
I posted a Forth programming challenge. I was very disappointed to get two AI answers and one human. I think the humans sussed out the solution and described an algorithm to Opus, but, the AI strategy produced one large page-filling word.
A top-level word filling one page, doing everything there except some subroutines mimicking C Standard Library.
In Forth, that chunk ought to be many smaller words. Heck, even in C (at least it fit in a page.)
Perhaps you just haven't used the correct AI yet? Perhaps none of us have in that Forth doesn't have much of a large dataset to train from?
Can you link to the programming challenge? It would be interesting to see if recursive language models that use double-blind latent space might work better.
Oh, also "Programming A Problem Oriented Language: Forth - how the internals work" by Charles Moore, the inventor of Forth. It conveys his design philosophy: simplicity. Time and again he makes the point "You don't need it." Where a simple solution fits 90% of use cases.
Where I think Forth falls short: it encourages you to "write your own language" or vocabulary, where that can superficially resemble "noun [adjective] verb" syntax, but doesn't have polymorphism. Then, there are N+1 versions of message-passing object-oriented Forth, where N is us.
Shame it didn't keep the coolest part of colorForth - the colors!
You change the meaning of word by changing their colors (is it a a 'runtime' function, macro or number? green, cyan or yellow), and the when you input the colors you also let the editor in a sense pre-compile the code so the interpreter becomes insanely fast.
The colors are in reality a byte prefix that acts as an index into a jump table so hardly any interpreting needs to happen, almost like a half-jit'ed language.
Also uses a weird encoding for text instead of ascii - it's a variable sized shannon encoding to make the most frequent english characters take fewer bits, from 4 to 7 bits.
This is imo the real spirit of Forth - simplify, simplify, simplify, make it an exact custom fit for your needs, screw standards.
15 comments
[ 3.0 ms ] story [ 48.5 ms ] threadDon't use AI, it writes Forth like it writes C. It has got better at following Standard, in Gforth style, but it is awful at the spirit of Forth: factoring programs into a vocabulary of tiny, reusable pieces.
I posted a Forth programming challenge. I was very disappointed to get two AI answers and one human. I think the humans sussed out the solution and described an algorithm to Opus, but, the AI strategy produced one large page-filling word.
A top-level word filling one page, doing everything there except some subroutines mimicking C Standard Library.
In Forth, that chunk ought to be many smaller words. Heck, even in C (at least it fit in a page.)
https://forums.atariage.com/topic/386161-solve-this-number-p...
Can you link to the programming challenge? It would be interesting to see if recursive language models that use double-blind latent space might work better.
https://forums.atariage.com/topic/386161-solve-this-number-p...
Just learned the stack operations and trying to get used to them, but I have some bigger projects in my personal backlog.
Lee Brodie:
1. Starting Forth. Somewhat dated (1979 FIG-Forth dialect)
2. Thinking Forth. Has software design lessons that go far beyond Forth.
These are free in pdf.
Elizabeth Rather, of Forth Inc:
3. Forth Programming Handbook. What I keep on my desk for Standard Forth.
4. Forth Application Techniques.
Dr. Ting has some good books. They're free pdfs now.
I also keep: Texas Instruments: TI Forth, by Leon Tietz, Leslie O'Hagan... and the vastly improved fbForth manual by Lee Stewart.
Where I think Forth falls short: it encourages you to "write your own language" or vocabulary, where that can superficially resemble "noun [adjective] verb" syntax, but doesn't have polymorphism. Then, there are N+1 versions of message-passing object-oriented Forth, where N is us.
https://youtu.be/giLsd-bik6A?si=Cfh5eeWZ2re7ji4C
Shame it didn't keep the coolest part of colorForth - the colors! You change the meaning of word by changing their colors (is it a a 'runtime' function, macro or number? green, cyan or yellow), and the when you input the colors you also let the editor in a sense pre-compile the code so the interpreter becomes insanely fast.
The colors are in reality a byte prefix that acts as an index into a jump table so hardly any interpreting needs to happen, almost like a half-jit'ed language.
Also uses a weird encoding for text instead of ascii - it's a variable sized shannon encoding to make the most frequent english characters take fewer bits, from 4 to 7 bits.
This is imo the real spirit of Forth - simplify, simplify, simplify, make it an exact custom fit for your needs, screw standards.
That is like making a lisp without macros - it takes away a lot of the fun.
I suspect the reason is because it compiles the code in one step whereas immediate words need to run at compile time.