Comment by FarmerPotato

7 days ago

Forth user here.

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.

I want to learn Forth. Do you have any good reference or know about some good code examples?

Just learned the stack operations and trying to get used to them, but I have some bigger projects in my personal backlog.

  • 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.

  • Still good:

    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.