|
FORTH programming language
|
introduction to FORTHFORTH is one of the most unique and ingenious programming languages ever invented. Interpreting and compiling are unified, the only difference between interpreting and compiling is a flag that controls whether a FORTH word is executed (interpreted) or stored into dictionary (compiled). FORTH has been implemented in 8 KB (eight kilobytes) of memory. In era of microcomputers, FORTH was ideal, functioned as an interactive programming environment. FIG-FORTH, amazingly, was written partly in FORTH inside assembly code. FORTH is best suited to writing very small programs. Postfix syntax of FORTH requires as much diligence as assembly language requires. Yet programming in FORTH progresses to very high-level code, by being based on words, top-level of a FORTH program will resemble English prose. FORTH provided an interactive programming system, this author once fixed a buggy FORTH word while FORTH program was running. |
FORTH documents
|
my versions of FORTHIn 1994...1995, this author ported 16-bit 8086 FIG-FORTH to 32-bit 80386 protect-mode from which three versions were assembled: PCDOS, PCDOS/DPMI, IBM OS/2 Presentation Manager. Boosted speed of FORTH using Direct-Threaded Code (DTC). 32-bit FORTH versions could multi-task. Version for IBM OS/2 used OS/2 thread model. For PCDOS version, wrote 80386 protect-mode monitor, a micro-kernel, which scheduled FORTH tasks defined as 80386 Task State Segments (later learned TSSs were slow).
VFOS (x86 protect-mode monitor) reflecting x86 exception back to VFORTH To draw graphics using FORTH words, wrote bindings to OS/2 Presentation Manager API using EMX GCC. The result was a unique program -- the only OS/2 PM program written in FORTH that exists in this galaxy.
FORTH startup on OS/2 with a 64MB (megabyte) dictionary |
White Lightning FORTH by Oasis SoftwareAn amazing version of FORTH. Full webpage is at: White Lightning FORTH & Basic Lightning by Oasis Software |
HES VIC FORTH and F-PCEver try to write a non-trivial program in 1KB (1024 bytes) of memory? Certainly can't be done in C++. On a standard VIC-20 with 5KB, VIC FORTH (VICFORTH) is left with only 1KB available for programs as FORTH dictionary. This author bought HES VIC FORTH, a cartridge, for a 13KB VIC-20 (5KB + 8KB expander) in ~1983. Compared to BASIC, FORTH was much faster, didn't exhaust memory, but easy to crash, more difficult to program, yet far more powerful language. F-PC for PCDOS, also written by Tom Zimmer (and others), was notable for being polished, had hypertext documentation (predated WWW/HTML). |
links
|
commentary/opinionpositive opinion
FORTH threaded-code compilers are tiny -- generally have zero bugs. negative opinion
Writing in FORTH is difficult because of notorious "stack juggling". controversial/undecidedOlder FORTH standards specified 16-bit FORTH virtual machine, threaded-code, format of FORTH words. So, by knowing how FORTH words are executed, programmers could tinker with internals of FORTH. Tinkering could be done whether system was 6502, Z80, 8086, etc. ANS FORTH standard left unspecified the internals of FORTH. Portability and generating machine-code were goals -- same goals as C. That unintentionally created an argument for writing in C instead, since ANS FORTH has lost major advantages FORTH once had with well-specified threaded-code standards. Still, ANS FORTH would be useful as part of the basis for future threaded-code FORTH implementations. comparisons
Syntax of FORTH is simple. Core FORTH words are precise.
Other languages have a hundred quirks and pitfalls in their syntax.
In FORTH, there's not a sliver of doubt how quotes
"FORTH remains the language of the pioneers who live on the fringe.
As civilization catches up with them ... they move further out on the cutting edge.
If this makes you uncomfortable, join the hordes of the mediocre and program in C."
|