A week or so ago I started out porting John Walker’s public domain Atlast Forth over to the Arduino. The code is highly portable, so who knows, maybe I’d get something going for the Uno, and maybe even the ATTiny85. Maybe.
I thought I’d do a little speed comparison to see if Atlast had any point at all to it. Micropython is an excellent and mature platform for microcontrollers, and is vastly superior to my own humble effort.
Anyway, do the speed test is to read a pin 20 times in a row and see how long it took.
The code on Micropython:
def fn(): for i in range(20): switch.value()
That took 845us (microseconds).
Here’s the equivalent code using atlast:
: t 20 0 do 23 digr drop loop ;
Here’s the timing function:
: u usecs t usecs swap - . ;
That took 29us.
Although my Forth is immature, and is quite inefficient in how it works, I am very happy about its speed relative to Micropython. So who knows, maybe it can add some value when Micropython is proving just a little too slow to be usable.