Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Julian Fondren Newsgroups: comp.lang.forth Subject: Re: Forth Performance Question Date: Wed, 10 Aug 2011 13:35:23 -0500 Organization: A noiseless patient Spider Lines: 62 Message-ID: <86zkjhjes4.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="cO8zBIpB9LiP7q+vFZIJrA"; logging-data="5493"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183wwwB+Ru/UZJHUaTkJMDfjHd7YAivAQ8=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (windows-nt) Cancel-Lock: sha1:3k94tfcyNcWrU7uXv0uMugY0Td0= sha1:EpVk4HEnNimucUoFBdZ2Dru3bks= Xref: x330-a1.tempe.blueboxinc.net comp.lang.forth:4695 Arnold Doray writes: > I am actually interested in Retro (small VM, which seems to be easy to > extend; reasonably good documentation and IMO nice language coverage). In > Retro, the correct loop syntax is: > > : test 1 100000000 [ foo ] times ; > > Reversing the order of the arguments causes the loop body not to execute. > Exactly what a C/Java programmer would expect. IMO, while Retro might be > "defiantly Non-ANS Forth compliant", its choice of syntax helps the C/ > Java programmer into using Forth. Except, you aren't learning Forth. You're learning Retro. You wouldn't've mixed up the arguments to DO .. LOOP if you had set out to learn Forth; as a suggested barrier to Java programmers, that's just absurd. Forth is amazingly flexible, both ANS Forth and ANS Forth + a small bundle of environmental dependencies. You want DO with your own argument order? : DO postpone swap postpone DO ; immediate You want TIMES ? : times ( u xt -- ) swap 0 ?do dup >r execute r> loop drop ; You want TIMES at compile time? : ]times ( u xt -- ) swap 0 ?do dup compile, loop drop ; immediate : 8* ( n -- 8*n ) [ 3 ' 2* ]times ; You want TIMES with a cute syntax? : call ( k -- ) >r ; \ : cont ( -- k ) r@ 2 cells + ; \ gforth : cont ( -- k ) r@ 5 + ; \ SF : { postpone cont postpone ahead ; immediate : } postpone exit postpone then ; immediate : times ( u k -- ) swap 0 ?do dup >r call r> loop drop ; : test ( -- n ) 5 5 { dup 2/ + } times ; You don't gain any freedom by throwing Forth away; you just lose Forth. It's like saying "I want to wear a neon pink cowboy hat, but people give me dirty looks, so - rather than wear the hat and accept the looks - I guess I'll just have to move to Zimbabwe." > > Unfortunately, unless I am mistaken, Retro is slow: My test above shows > that it is more than 10x slower than Gforth. > gforth is more than faster. It's also of a community with extremely good commercial systems that you could very plausibly 'escape to' should its performance become a problem.