I've been a user of Forth for a long time, but I've never become an expert. The only active Forth community I know of is the newsgroup, comp.lang.forth which is fairly active.
I'm just curious how popular this language this among the hardware oriented crowd. The language is close to the metal so to speak and its interactive nature makes it ideal for working on or with hardware.
I know python is popular with the rPi crowd. Not sure what is mostly used on the Arduino. I do know Forth is available for those platforms and many others. In fact, it is hard to find a processor Forth hasn't been ported to.
Anyone here using it, why or why not?
Hi Rick,
I'm still using Mecrisp-Stellaris Forth, and have been since 2014.
I use it because Forth, due to its unique nature is a hotbed of innovation. Sure the original Forths from the 70's are long out of date now except on old processors of that era, but nowadays Forth runs on todays MCU's with modern development support.
Anyone who thinks we still use that ancient Forth stuff probably thinks we drive a Stanley Steamer, instead of a Tesla.
For instance my Forth terminal uses the ARM SWD facility (with a PC client terminal) for comms and uploading source. It's so fast that the Forth Core has to halt on errors (because it's too fast to see) but it also highlights errors in red text.
It has no dependency on the USART, or the System Clock. I can change the System Clock from 48Mhz to 8 Mhz and I don't lose terminal comms.
We also have a program that transforms any CMSIS-SVD to memory mapped Words, and bitfield Words in an intelligent manner, for instance if a bitfield is a single bit and read-only, the generated Word appends a "?" and creates a bit-test Word as below.
: RCC_CR_HSIRDY? ( -- 1|0 ) 1 bit RCC_CR bit@ ; \ RCC_CR_HSIRDY, Internal High Speed clock ready flag
A STM32F746 has 14,338 bitfields and they are all auto transformed into Forth Words, which would be impossible to do manually. The C programming Language also uses CMSIS-SVD to create its header files, as does RUST etc.
The transformed Words are easily inserted into my source using a vim editor key, no copy and paste is required. Because the transforms include the 'description' field, this often means that I don't need to consult the Technical Manual, some of which are over 3000 pages.
We also have Register Print Words for easy development and bug fixes. Here you can see that the HSI clock is on and ready, the HSE clock is on and ready and the PLL (phase locked loop) is also on and ready. This is of course in interactive *real time* as only Forth can do.
RCC_CR. $03035183
P H H
L P C S S H H
L L S E E S S H
R L S B R E I S
D O O Y D O| HSICAL | | R I
Y N N P Y N|7:6:5:4:3:2:1:0| HSITRIM | D O
|2|2| |1|1|1|1|1|1|1|1|1|1| | |4:3:2:1:0| Y N
~|~|~|~|~|~|5|4|~|~|~|~|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|~|1|0
0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 1 0 1 0 0 0 1 1 0 0 0 0 0 1 1
I just took that screepic, right now, on a running STM32F0 Discovery board.
My project management system includes the Fossil SCM, and uses the Sphinx document system complete with indexes and cross refs to auto generate a README.HTML project file.
I used Mecrisp-Stellaris to create a bootable binary for diagnosing the infamous Blue Pill board, to determine what MCU is actually in use. Is it a genuine STM32F103C8 or a Chinese 'clone' ?
It also tests if the MCU has a 'hidden' extra 64KB of flash by writing and reading every Byte.
This binary has been downloaded over 1000 times now, mainly by Windows users in the USA who can easily use the boards USB to obtain the menu via any serial terminal.
Mecrisp-Stellaris runs on most Cortex-M's out there, Mecrisp-Ice runs on Lattice FPGA's, Mecrisp-Quintus runs on RISC-V and MIPS, Mecrisp-Across uses a Cortex-M4 to cross compile for a MSP430 using a JTAG tether. It produces a 80 byte bootable Blinky binary in exactly the same way that C does, i.e. multiple compiler passes and easily fits on a MCU with only 500 bytes of Flash/Fram or whatever.
In the last week, Mecrisp has been ported to the RP2040 and currently is running in Ram only. Running from Flash is still under development. It uses the RP2040 USART and all the source is written in assembly. I imagine it won't be long before a SWDCOM terminal(s) are available for each CPU.
Everyone who actually uses Forth here on this forum will understand what I've just written and I apologize in advance to the C and Python users who probably gave up by line 16 as it's all too weird.
Rust users probably thought, 'that's interesting, I'll have to look into the parts I don't grok'.
LISP users probably said. 'cool! but what's a MCU' ;-)