Subject: Re: Theory #51 (superior(?) programming languages) From: Erik Naggum <firstname.lastname@example.org> Date: 1997/01/25 Newsgroups: comp.arch,comp.lang.lisp,comp.lang.scheme Message-ID: <email@example.com> * Scott Schwartz | Just to be fair, you ought to measure the same thing. In the first | case you measure the time to load and initialize the C runtime system. | In the second case you already have Lisp fired up, so you omit the | measurements for the cost of doing that. Let's see the time for the | a.out generated by ACL or CMUCL, starting at the shell prompt. right. the usual reaction from "C just _has_ to win"-people is to force everything to fit its paradigm. when C loses by a factor of 2, it has to be explained away with some nonsense like the above. a Lisp system is like a shell. in Unix, the shell evaluates your command line, including forking and running programs and whatnot. in Lisp systems, Lisp evaluates your expressions. if you goal in life is to get something done efficiently, you measure what is natural in each environment. if your goal in life is to execute a.out files efficiently, never mind what they do, then, and only then, should you generate a.out files for all test cases. but let's see what difference the runtime system _does_ make. ACL has a nice foreign function interface that should even out the costs: lotto.c is now compiled with gcc -c -O3 -fPIC. (load "lotto.o") (ff:defforeign 'c-lotto :entry-point "_lotto" :arguments '(fixnum fixnum) :return-type :integer) user(40): (time (lotto 35 7)) ; cpu time (non-gc) 4,567 msec user, 0 msec system ; cpu time (gc) 0 msec user, 0 msec system ; cpu time (total) 4,567 msec user, 0 msec system ; real time 4,591 msec ; space allocation: ; 2 cons cells, 0 symbols, 32 other bytes 6724520 user(41): (time (c-lotto 35 7)) ; cpu time (non-gc) 4,417 msec user, 0 msec system ; cpu time (gc) 0 msec user, 0 msec system ; cpu time (total) 4,417 msec user, 0 msec system ; real time 4,431 msec ; space allocation: ; 4 cons cells, 0 symbols, 32 other bytes 6724520 (these are stabilized values, i.e., time repeated the same values several times in a row.) we recall that the C function in the fork-and-execute version used 4.42 seconds of user time. in other words, the difference is negligible. note: the foreign function interface to CMUCL is less well documented, and I have never used it much. however, I'm using Allegro CL for a project that uses lots of binary protocols for which we already have working code. #\Erik -- 1,3,7-trimethylxanthine -- a basic ingredient in quality software.