barmar@mit-eddie.UUCP (Barry Margolin) (03/19/85)
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
tjj@ssc-vax.UUCP (T J Jardine) (03/21/85)
> 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)? ... I won't try to speak about what others mean, but I know that what I mean when I say that Fortran is "better" for numeric computations has nothing to do at all with a=b*c or its ilk. Certainly with appropriate attention to detail Lisp can handle (setq a (* b c)) with just as much efficiency. Fortran (or Pascal, ...) is a more appropriate choice if the numeric computations are at a higher level, such as the computations involved in simulating the flight dynamics of an air vehicle, or in solving celestial navigation problems. In such a case the optimum is that the problem solution already exists and one must "link" to the solution and obtain its results. In a slightly less optimal situation a library of subroutines/functions exists which need to be coupled in some obvious way and then this coupling "linked" to the Lisp environment to obtain the solution. The point is, I believe, that just because we have Lisp, or a new "AI problem solving approach" does not mean that we should reinvent all problem solutions using this new approach. Decision tables still provide an effective problem solving tool for certain classes of problems -- why not use such a capability when it is applicable? It may be the case that other factors will influence us to rewrite a solution using our new tool or approach -- I hope I don't ever have to write another communications control program in COBOL, for example, although COBOL was indeed capable of handling the particular problem at the time. By the way, double precision floating point is the default in Franz Lisp (I haven't yet found a way to create a single precision variable, but haven't pursued it that far), and I know double precision is also available in Zetalisp. The list very likely larger than just those two -- Common Lisp probably has it. Ted Jardine TJ (with Amazing Grace) The Piper Boeing Artificial Intelligence Center ...uw-beaver!ssc-vax!bcsaic!ted -- TJ (with Amazing Grace) The Piper Boeing Artificial Intelligence Center ...uw-beaver!ssc-vax!bcsaic!ted
joe@petsd.UUCP (Joe Orost) (03/22/85)
Could we PLEASE keep the Fortran vs. Lisp debate out of net.lang.ada. It has nothing to do with Ada! --joe
rggoebel@water.UUCP (Randy Goebel LPAIG) (03/22/85)
Does anyone remember why this discussion about LISP versus FORTRAN is in this newsgroup? If not, I suggest that it get moved or removed.