Follow

I've been digging really hard into just lately out of curiosity and let me tell you, it is deeply weird. Way weirder than Lisp or Tcl. It uses raw pointers as integers and uses them for basic variables, but supports compile-time evaluation. You have to manage the stack manually, but good style means arranging things to read like prose.

My only complaint is that most big Forth projects seem to be proprietary because there's almost no good codebase online.

The book I'm reading has contempt for storing source code in variable-length, named files. Numbered discrete blocks of 1k keep one honest and upright. Also, the Forth system will swap these blocks in and out of memory as needed.

I love it because it smacks the exact boundary of the abstract and the visceral machine. It's equal parts beauty and wtf.

I consider its complete lack of guardrails to be a terrible flaw for actual use, though. Hold it wrong and it will silently drape you in monofilament before slicing you to ribbons. I'm barely smart enough for C here.

I guess an experienced Forthwright (a crime that the word was never used afaict) would say that you should structure your words so that mistakes are obvious. It's possible that this is true - there's a lot less to obscure the definition of operations.

Compare with C:
Int square(int n) { return n*n; }

The same in Forth:
: square dup * ;

@dl It is weird and exciting at the same time, and I return every few years to study it a bit more. What I find really amazing is that even though it is a small system, it still gives a lot of food for thought.

The books to read are Starting Forth and Thinking Forth by Leo Brodie, I hear repeatedly.

Here's a thread with some substantial programs to read: atariage.com/forums/topic/3274

@hanshuebner This is a great link, thank you!

I've been working my way through both books. Thinking Forth is mostly interesting because it was written in the 80s and the advice sounds almost identical to advice given today. Very little of it is specific to Forth.

Sign in to participate in the conversation
Cantos.social

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!