From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site mit-eddie.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!barmar From: barmar@mit-eddie.UUCP (Barry Margolin) Newsgroups: net.ai,net.lang.lisp,net.lang.ada Subject: Fortran better than Lisp for numerical code? Message-ID: <3829@mit-eddie.UUCP> Date: Tue, 19-Mar-85 01:45:00 EST Article-I.D.: mit-eddi.3829 Posted: Tue Mar 19 01:45:00 1985 Date-Received: Wed, 20-Mar-85 04:08:41 EST References: <253@bu-cs.UUCP> <320@cmu-cs-k.ARPA> Reply-To: barmar@mit-eddie.UUCP (Barry Margolin) Organization: MIT, Cambridge, MA Xref: watmath net.ai:2639 net.lang.lisp:402 net.lang.ada:242 List-Id: There has been much discussion of late about comparing Lisp and Fortran for numerical code. Many people have either stated or implied that Fortran should be better for number crunching than Lisp. Why do people believe that? Why should a Fortran compiler produce any better code for A=B*C than a Lisp compiler would produce for (setq a (* B C)) (assuming, in the latter case, appropriate declarations or use of non-generic functions)? Fortran is not a very complex language, but neither is Lisp. The only argument I can think of is that people assume that Lisp compiler implementors would not bother optimizing the numeric code, but would concentrate on the list processing code. However, by the time the compiler is doing much of its optimization (peephole, register allocation) most of the distinction is gone. In fact, many things in Lisp make it EASIER to optimize. For instance, in Fortran it is possible to jump into the middle of a DO loop from outside the loop (I have a vague feeling that something like this was declared invalid in Fortran-77, but there must be other similar examples), while it is impossible to transfer into a Lisp do-loop. This means that less program analysis is necessary in order to produce very good code for a loop in Lisp than Fortran. The only other thing I can think of is that I don't know of any Lisp implementations with double precision floating point (I suspect that floating point was added to Lisp in the first place only grudgingly). So, people that want more floating point precision should still use Fortran (of course, if they want EXACT answers they should use Lisp with bigna, which often have not only more precision but more range than most floating point implementations). -- Barry Margolin ARPA: barmar@MIT-Multics UUCP: ..!genrad!mit-eddie!barmar