[clean-list] God must be programming in Clean

Richard A. O'Keefe ok@atlas.otago.ac.nz
Fri, 10 Aug 2001 12:51:14 +1200 (NZST)


Note that depending on which C compiler it is and what the options are,
compiled C code for the *same* source file can vary in speed by a factor
of 5.

Note also that before anyone complains about the speed of their Lisp code,
they should read their documentation carefully to see which optimisation
features are particularly helpful in that system and which are not.
They should also use the (unfortunately vendor-dependent) facilities
provided by their Lisp system to see how their Lisp code was understood
by their compiler.

Note finally that Lisp is not designed to make trivial floating-point
loops go especially fast; Lisp compiler writers have other priorities
and other benchmarks.

For what it's worth, on my machine Haskell code compiled by GHC 4.08
ran at 80% of the speed of the C code, and could have been more if I
had bothered to read the manual to find out how to pass better options
on to the C compiler used as a back end.  At Scheme (no compile-time
types at all, not even any Lispy optional declarations) ran at the same
speed as the C code.  (Thank you Jeff Siskind for your wonderful Stalin 0.8.)

Gonzi's Clean version:
	
	module cosx
	import StdEnv
	
	test::!Int !Real -> !Real
	test n cosx
	        | n==0 = cosx
	        | otherwise = test (n-1) (cosx+cos(cosx))
	        
	Start = test 10000000 0.0
	
My Scheme version:
    (let loop ((n 10000000) (x 0.0))
      (if (zero? n)
	  (begin (display x) (newline))
	  (loop (- n 1) (+ x (cos x)))))

What does this tell us about the relative merits of C, Lisp, Clean,
and Scheme?

Nothing, really.  If it did, people wouldn't be using Java.