Ask HN: Why does Lisp need to be slower than c?
It's easy to program in an imperative style in lisp. I can't think of any language feature C has that can't be used by lisp. Why can't lisp become as fast as C by using only a fast subset of a given lisp dialect?*
*I know, if you only use C features you're writing C. There's must be advantages to having lisp all the way down though. Having a fast C-esque lisp subset would make going from prototype code to performance-intensive code much, much easier.
9 comments
[ 4.3 ms ] story [ 36.5 ms ] threadAnd if you discover that you have the wrong approach, it is much easier to change a Lisp program than a C or a C++ program. That is my primary definition of fast.
Speed of program execution is often (not always) overrated.
www.lrde.epita.fr/~didier/research/verna.06.imecs.pdf
http://www.foldr.org/~michaelw/log/programming/lisp/reverse-...
And there are more papers on the subject (google for it)
See: How to make LISP go faster than C, http://docs.google.com/gview?a=v&q=cache:pJg0zHyA8s8J:ww...
As an example, consider C pointers. The compiler never knows if two objects passed by reference are going to overlap in memory, so it can't do certain optimizations that seem obvious to a human that "knows" the pointers won't overlap.
1. The fastest possible implementation is possible in C.
2. Lisp will never "be faster" (the limited meaning of "be faster" we are considering in this context) than C because that is impossible.
3. Any difference however minor, will cause Lisp to be slower.
Thus it is highly likely that lisp will be slower.
NOTE: commenter rejects your notion of slower.
How about a new premise: Why do LISP programmers write slow programs?, and if that premise gets shot to pieces, how about Why do people think LISP programmers write slow programs?.
Down side of C is that every little algorithm or pattern needs to be made from scratch as there is almost none functionality in the language itself. What people see as C is most often the nowadays immense library of solutions. Upside is it's proven flexibility, C can do almost anything and is to be found on every platform out there.
Lisp is mainly about a certain functionality, that is list processing, so you are comparing a general purpose language with a specialist one. In other words, you are comparing apples and pears.