[PicForth] food for thought - picforth as compiler back-end
David McNab
david at rebirthing.co.nz
Fri Dec 17 01:37:05 CET 2004
Hi,
My recent quietness on this list can be explained by the fact that I'm
trying out the CCS C compiler, and am quite impressed so far with its
performance - seems to be the most practical C-like compiler for PIC. I
might well make an exception to my usual 'free software only' principles
and buy a copy.
Regarding PicForth - I reached a situation of getting frustrated with
the Forth language in general. Annoyances such as:
- constant need for stack accounting
- ease of introducing fatal bugs
- application code tends to be far less readable than its equivalent
in other languages like C, even with prolific stack-effect comments
- coding/debugging effort is (at least for me) greater with Forth than
for traditional languages like C.
- forth compilers are far less capable of picking up bugs (eg function
argument/return mismatches) than compilers of other languages
All this said - PicForth does offer one beautiful thing - its capability
to understand a procedural, stack-capable language higher-level than
assembler, and generate efficient, compact and largely reliable code.
So a thought hit me - PicForth could be used as a back-end for compilers
of other high-level languages such as Python, C, Ruby etc. A parser
could be written with the usual tools (eg yacc/bison, PLY, Jack etc).
Converting the parser's generated AST into PicForth source code would
take a fraction of the work of the traditional practice of generating
assembler or machine-code.
I'm going to attempt a Python to PicForth compiler, and see how far I get.
Thoughts anyone?
--
Cheers
David
More information about the PicForth
mailing list