Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!mcnc!ecsvax!dgary From: dgary@ecsvax.UUCP Newsgroups: net.lang,net.lang.forth Subject: Re: FORTH efficiency Message-ID: <2867@ecsvax.UUCP> Date: Mon, 9-Jul-84 14:45:45 EDT Article-I.D.: ecsvax.2867 Posted: Mon Jul 9 14:45:45 1984 Date-Received: Wed, 11-Jul-84 03:37:59 EDT References: lanl-a.9623 Lines: 38 <> The referenced article notes that FORTH is often not efficient when compared to compiled languages, giving as an example the phrase A @ B @ + C ! and its FORTRAN equivalent C=A+B. Two comments: First, FORTH is properly advertised as a fast, space-efficient interactive development language. The operative word is 'interactive' which almost (obviously, not quite) implies 'interpretive'. FORTH is rather speedy as interpretive languages go. Furthermore, all 'real' FORTHs include an assembler so that time-critical routines (typically a small part of most applications) can be coded in assembler and then tested interactively. FORTH is often best used as an interactive assembler. A few ridiculous claims have been made for FORTH speed. The most ludicrous is the assertion that FORTH code often executes faster than the equivalent assembler program (!!!) an outrageous claim from no less than a FORTH Interest Group (fig) brochure. As for the example given, it is possible to speed it up by using constants instead of variables, and writing a FORTH word that stores a new value in a constant. That would make the phrase something like: A B + := C (The := word has to be IMMEDIATE and is best done in assembler, but : := ['] ! ; IMMEDIATE would probably work (haven't tried it), although you may need to get rid of the brackets.) D Gary Grady Duke University Computation Center, Durham, NC 27706 (919) 684-4146 USENET: {decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary