[chbot] Forth for embedded programming.
Paul Davey
plmdvy at gmail.com
Sat Nov 5 04:58:23 GMT 2011
On Sat, Nov 5, 2011 at 1:58 PM, Carl Ranson <carl.ranson at gmail.com> wrote:
>
> My impression is that its one of those languages that looks good at
> first glance but rapidly degrades as the project goes.
>
> Even something as simple as generating the fibonacci sequence becomes
> unreadable
>
> : fib ( n -- fib )
> 0 1 rot 0 ?do over + swap loop drop ;
>
> It seems that it is impossible to read the code without also considering the stack at each step.
>
Forth does have a reputation for being a write only language, it is
difficult to write properly readable forth. The stack has to be
considered at every step as this is the equivalent of the variable
state in C like languages, the difference is that we can deal with the
C like abstraction better without practise.
I kinda like forth and I do like it on micro-controllers as you can
have the compiler on the device and develop it over a serial console.
The language is hard to write cleanly in though and requires a lot of
commenting and careful structuring to make it readable.
I do like forth as a concept though it is very simple and elegant in a
way, threaded code is an interesting idea as well.
Just a few fractured thoughts on Forth.
Paul
More information about the Chchrobotics
mailing list