A new word added to 4tH

12 views
Skip to first unread message

The Beez

unread,
Jan 17, 2026, 8:43:25 AMJan 17
to 4tH-compiler
Hi 4tH-ers!

I recently made a video about encoding the Chao cypher in 4tH. And that one was highly educational - at least to me. I came across a sequence >R OVER R> SWAP, which kind of irritated me, because it smelled like stack acrobatics.

Later it dawned to me, it was a familiar word, called THIRD in COMUS. It was proposed by my mentor - and although I hold this guy in high regard, I don't like this name. It doesn't fit in the line of DUP, SWAP, ROT.

Now, it also has another name, PLUCK. Not quite happy with that, but better than THIRD. So, next step was to see how often it had been used. Very few times in application programs, but quite often in libraries. Most uses are not by my hand, but still - they're part of 4tH. 

So, I implemented it as an inline macro (internal word, expanded by the compiler itself). And I replaced all former uses in the repository by PLUCK.

While I was at it, I came across the "wildcard" libraries. Now, these are relatively old (2006 and 2014), so I patched them up. Note - these are not too beautiful. Just out of curiosity I recoded them. And this came out of that exercise:

- The new code is much more understandable;
- The new code is less than half the size of the old one (in opcodes);
- The new code requires NO libraries at all;
- The new code also works with addr/count strings (not ASCIIZ);
- The new code uses two variables (instead of none);
- The new code balances the parameters between the Data and the Return stack (less stack acrobatics due to shallow stack usage).

I thought that was quite interesting. Code in SVN.

Hans Bezemer

Ron K. Jeffries

unread,
Jan 17, 2026, 10:13:32 AMJan 17
to 4th-co...@googlegroups.com
Half the size? You are amazing!

Unrelated: I wonder what it would take to teach one of the coding AI systems to write competent 4tH programs.

Be well (and prosper)

---
Ron K. Jeffries





--
You received this message because you are subscribed to the Google Groups "4tH-compiler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 4th-compiler...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/4th-compiler/f1d9b741-7ed1-4f8b-9d6c-a425787e2508n%40googlegroups.com.

The Beez

unread,
Jan 17, 2026, 1:34:25 PMJan 17
to 4tH-compiler
Ron!

Great to hear from you, man! I missed you! (But I changed the intro to my videos as promised ;-)

As far as AI goes to Forth programs, I have gathered some information in the meanwhile:
  1. I've frequently asked the AI: "write me an integer square root routine in Forth". Sure, I got an answer. It looked legit, but never, ever did it run properly. Either it didn't compile, or it bombed out at runtime. I've almost given up;
  2. A commenter claimed he used Forth to test AI vape programming. His experiences were identical to mine;
  3. I discussed code generation with a guy who forced the poor thing to write BASIC programs. Yeah, it compiled, yeah, it ran, but the results were underwhelming.
And I understand why - because there's a lot to do. Assigning values to the two stacks, duplicating them when they are used destructively, mixing in the complications of branching and looping for good measure. That's quite a lot.
Talking about all that - that's IMHO why I was able to slash the size of the "wildcard" library in half. 
Using my own methods it was MUCH easier to distribute the values between the stacks - and design proper abstractions. E.g. since there was a lot of pointer calculation, I used 2OS as pointer and calculated the end value of that pointer value by CHARS +,  like a+n a. That way any comparison would simply condense to OVER OVER >.
I also noticed that the two temporary values would be best served as variables, because bringing it TOS would require a ROT. Retrieving 3ORS would be even worse - especially since that wouldn't be the only stack juggling required. The old routine held all the strings on the Data Stack - hence all the movement - and the use of 4DUP, 4DROP, etc.. So yes, I definitely learned some new stuff. That'll get you to half the size.

Again, good to hear from you!

Hans Bezemer

Ron K. Jeffries

unread,
Jan 17, 2026, 3:30:29 PMJan 17
to 4th-co...@googlegroups.com
Thanks again. What I wonder is why the AI coding programs e.g. Claude or others apparently do so well with common languages. My SPECULATION is there's such a dearth of Fort nevermind the 4thH dialect that the LLMs have not been adequately trained. It would be a fascinating curiosity project to learn how to dump in  large body of your (open source I believe) as training material

I don't know if you are familiar with Dave Winer, (see http:scripting.com) He is an OG software developer and long time blogger. He has adopted Chat GPT and uses it agressively. He has serious developer cred, which makes me think there is a "there, there:.

Please understand: I am but a curious looky loo; 
//A "looky-loo" is an informal term for a person who is curious and stops to look at something, often without any intention to buy or engage, such as at a scene of an accident or a property for sale. It can also carry a slightly negative connotation, implying intrusive curiosity.
 
Be well sir. You are genuinely amazing.
Reply all
Reply to author
Forward
0 new messages