Re: C/C++ speed optimization bible/resources/pointers needed!
- From: Jerry Avins <jya@xxxxxxxx>
- Date: Fri, 27 Jul 2007 22:51:44 -0400
Peter J. Holzer wrote:
["Followup-To:" header set to comp.programming. None of the other groups
seems appropriate, and I don't want to cross-post to two completely new
groups]
On 2007-07-27 12:15, srp@xxxxxxxxxxxx <srp@xxxxxxxxxxxx> wrote:But in order of code optimization, from worst to best, you have C++,
straight C, and Forth as best by far. C is simply no match for any
flavor of Forth for low level code optimization.
The results of the debian language shootout don't agree with you:
http://shootout.alioth.debian.org/debian/benchmark.php?test=all&lang=gforth&lang2=gcc
For almost all benchmarks the C code is faster than the Forth code.
It is of course possible that the person who wrote the forth benchmarks
wasn't a good forth programmer, or that "GForth" is a particularly bad
Forth implementation, but in the first case the OP is almost certainly
in the same position (very few people are experienced Forth programmers
these day) and in the second case the claim "C is simply no match for
*any* flavor of Forth" is false as GCC is clearly a match for GForth.
Forth is my preferred programming language. Forth programs tend to be fast for reasons other than sheer execution speed. If that sounds like bull*** -- I can well understand that it might -- don't argue with me, start a thread on comp.lang.forth.
Forth began as a threaded language, its primary goal being compact code. That made much sense when 32K words was a generous amount on a minicomputer, but it makes little sense now. GForth is a threaded version, slow by modern standards, but worth using for int many conveniences. It is compatible with the ANSI standard for Forth. There are other more modern Forths with compilers that produce optimized machine code and are much faster. Those compare favorably with C compilers, but I don't believe that Forth routinely beats C for the same algorithm, although it at least comes close.
Incremental coding and testing makes the production cycle shorter, which is why I like it. Compare C speed to SwiftForth, VFX Forth and IForth.
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
.
- Prev by Date: Re: Bignum looses precision too fast?
- Next by Date: Re: Choosing a PL - What you can do or how you do it?
- Previous by thread: Multiple #defines in WinError.h
- Next by thread: Re: Thoughts on the C/Assembly Debate
- Index(es):