Path: utzoo!utgpu!attcan!uunet!tektronix!tekcrl!tekgvs!toma From: toma@tekgvs.GVS.TEK.COM (Tom Almy) Newsgroups: comp.lang.forth Subject: Re: FORTH and memory Message-ID: <3767@tekgvs.GVS.TEK.COM> Date: 2 Aug 88 16:37:48 GMT References: <8807211846.AA27919@jade.berkeley.edu> <9428@dartvax.Dartmouth.EDU> <2353@pt.cs.cmu.edu> <1530@crete.cs.glasgow.ac.uk> <132@kolvi.hut.fi> <17597@glacier.STANFORD.EDU> <2529@pt.cs.cmu.edu> Reply-To: toma@tekgvs.GVS.TEK.COM (Tom Almy) Organization: Tektronix, Inc., Beaverton, OR. Lines: 41 In article <2529@pt.cs.cmu.edu> ns@cat.cmu.edu (Nicholas Spies) WRITES: >I think it's hard to generalize about interpreters, because there is more than >one way they are implemented. [...] >Several Forths permit colon definitions to be compiled as in-line code, >avoiding all threading during execution (but usually using more space). The >ones I know about are HSForth and PCForth (both for PCs) and Mach2. Well since my Native Code Compiler (in PCForth) was mentioned, I'll comment. Normally PCForth (and the newer URForth, also by Laboratory Microsystems) compile into threaded (the former indirect, the latter direct) code. The NCC allows compiling individual colon definitions into machine code. The only change ususally required is to change ":" to "COMPILE:". Of course, all this is fully interactive, you can type in a COMPILE: definition from the keyboard. Space used ranges from slightly more (on average) for PCForth to considerably less for UR/Forth 386, whose threaded code uses 32 bit pointers. With UR/Forth, which has segments, there is considerably less use of the data segment, and considerably more use of the code segment. This is typically advantageous since most applications run out of data segment space (which holds data and threads) well before code space (machine code). The benchmark ": BENCH 10000000 0 DO LOOP ; " (YES, TEN MILLION) running under UR/Forth 386 on a 20Mhz 0ws box got the following results: Speed Space Threaded Code 14.9 seconds 44 bytes NCC 5.6 seconds 12 bytes By the way, I have also written a batch FORTH compiler, which works like "traditional" languages -- 1. edit, 2. compile, 3. debug, 4. goto step 1, which compiles and links to an executable program in a single pass. This compiler has proven exceedingly unpopular because Forth programmers consider traditional compilers anathema, while traditional compiler users consider Forth anathema! Tom Almy toma@tekgvs.TEK.COM Disclaimer -- The above is not connected in any way with my employer, Tektronix. I do get royalties from the Native Code Compiler and the CFORTH Forth compiler.