JUERGEN <
epld...@aol.com> writes:
> In another thread I started, I tried to find a basic Forth under
> MicroPython
I sort of remember that, but I don't see any point in implementing Forth
in Python. The idea of Forth is to get an interactive language from
very little machine resources, that is capable of realtime operation,
and is pretty fast for an interpreted language and that can also be made
very fast with an optimizing compiler. The cost of this is quite a bit
of programmer inconvenience in dealing with the stack, memory
management, lack of compiler and runtime automatic error checking, etc.
Python has lots of such conveniences, but the cost is that it's much
slower than Forth, uses much more memory, is not realtime (uses
automatic storage reclamation or garbage collection), etc. By
implementing Forth in Python, you get both the inconvenience and the
high resource consumption and slow speed.
> Having this in MicroPython should allow to have a complete GFORTH run
> under MicroPython.
Gforth is written in C and you have to compile it with a C compiler.
Python doesn't come into it. In principle you could write a Forth in
Python but there's little to be gained from that.
> How effective - is it fast enough to play with is my question?
MicroPython is more than fast enough to play with. Maybe it's 10x
slower than Forth on the same hardware. On the other hand, current
hardware at least 100x faster than the 1980s computers from Forth's
heyday, so if you're used to running Forth on those, Python will seem
10x faster, if that makes any sense.
If you implemented Forth in Python straightforwardly, maybe you'd get a
10x slowdown, so you're back to the original speed of Forth on old
computers.
If you type "Maple Mini" into ebay, you should see lots of cheap boards
(like 5 euros or less) with the old Leaf design, which is a Cortex M3
with 128k of flash and 20k of ram, at something like 80 mhz. That
should be enough to run small Micropython programs, though you probably
want more ram for bigger programs.
The Micropython PyBoard is much nicer and comes with Micropython already
installed, though it's fairly expensive (45 USD over here). You can
play with one online, typing Micropython commands into your browser to
watch the board control a servo and some leds:
http://micropython.org/live/