Tech News
← Back to articles

Forth – is it still relevant?

read original related products more articles

Forth - is it still relevant?

With all the advantages, it is unfortunate that Forth lost out to C language over the years and have been reduced to a niche. Per ChatGPT: due to C's broader appeal, standardization, and support ecosystem likely contributed to its greater adoption and use in mainstream computing.

So, the question is, how to encourage today's world of C programmers to take a look at Forth. How do we convince them that Forth can be 10 times more productive? Well, we do know that by keep saying how elegant Forth is or even bashing how bad C can be probably won't get us anywhere.

Bill Muench created eForth for simplicity and educational purpose. Dr. Ting, ported to many processors, described Forth in his well-written eForth genesis and overview. I like the idea and decided to pick it up.

eForth now - What did I change!

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. Dictionary is just an array. It's remodeled from linear memory linked-list to an array (or a vector in C++'s term) of words. To search for a word, simply scan the name string of dictionary entries. So, to define a new word during compile time is just to append those found word pointers to the its parameter array one by one.

To execute become just a walk of the word pointers in the array. This is our inner interpreter.

Hashtables might go even faster but we'll try that later. Data and Return Stacks are also arrays. With push, pop and [] methods to clarify intentions. Parameter fields are all arrays. Why not! No vocabulary, or meta-compilation. Except CREATE..DOES>, and POSTPONE, these black-belt skills of Forth greatness are dropped to keep the focus on core concepts. Multi-threading and message passing are available From v5.0 and on, multi-core platform can utilize Forth VMs running in parallel. see the multi-threading section below for details A thread pool is built-in. Size is defaults to number of cores.

Message Passing send/recv with pthread mutex waiting.

IO and memory update can be synchronized with lock/unlock.

... continue reading