Why is Python popular, while Lisp and Scheme aren't?

Fernando Pérez fperez528 at yahoo.com
Sun Nov 10 16:28:43 EST 2002


Jacek Generowicz wrote:

> Recently, I wrote a number-crunching program in Lisp. A typical
> function in which look something like this:
> 
> (defun Hpp (x s z)
>   #i(sqrt(Vpp(x s z)-gamma)/(x^2+s^4) -
>      exp(sin(Tpp(x s))/(2*b1(x s)))))
> 
> (Incidentally, Lisp's _syntax_ made it possible for me to write a
> macro which automatically re-structures my numerical functions in a
> way which makes the program run 17 times faster.)

Would you care to elaborate a bit? I'm honestly interested. Please keep in 
mind that I:

- know next to zero about lisp
- have a pretty solid scientific computing background (I see you're from CERN, 
I do lattice qcd).

So please be gentle on the lisp, which is what I'm interested in learning 
about, but don't pull any punches on the numerics. I want to know 
_specifically_ what kinds of transformations you were able to perform to 
enhance the performance of your numerical code.

> Continuing the clisp session from above:
> 
>   [2]> (/ 2 3)
>   2/3
>   [3]> (+ 1 2/3)
>   5/3
>   [4]> (sqrt -1)
>   #C(0 1)
> 
> Hmm ...
> 
>   jacek > python2.2
>   Python 2.2.1 (#3, Jun  4 2002, 09:56:27)
>   [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
>   Type "help", "copyright", "credits" or "license" for more information.
>   >>> import math
>   >>> math.sqrt(-1)
>   Traceback (most recent call last):
>     File "<stdin>", line 1, in ?
>   ValueError: math domain error
>   >>> 2/3
>   0
>   >>> 1 + 2/3
>   1
> 
> ... perhaps Python was invented before math and rational and complex
> numbers (yes, I *do* know Python has complex numbers, just FUDding in
> your style, yes I *do* know that integer division is Python is being
> fixed).

Indeed, Python's complex and rational number support is pretty lousy, and a 
frequent source of frustration to me. I don't expect tensors or groups to be 
basic data types of a language, but rational and complex numbers _should_ 
have been there from day 1.

I have a question for you (keeping in mind what I said above about my 
background in HEP, moving these days towards algorithm development). Could 
you try to outline what things someone like me would benefit from in Lisp? 
The full extent of my lisp experience is modifying my .emacs file :) While I 
admit that the parenthesis issue annoyed me a bit, I know full well that if I 
can find in the language a significant benefit, I'll get over that in one 
afternoon.

I've become a huge python fan recently (out of Pascal, C, C++, Perl, IDL, 
Fortran,... I like it best). But I'm _honestly_ interested in learning a bit 
about what Lisp brings to the table. Specifically, what is there in Lisp 
which is natural/possible which is in python difficult/impossible, with an 
eye towards numerical/scientific computing? I know they are both Turing 
complete, but that point is moot. If I cared about it I'd be writing in 
assembly.

I'd very much appreciate an overview of this by you or anyone else with a good 
lisp background. Just to reiterate that I'm _not_ interested in a language 
flamewar:

- I don't care about the parentheses. Enough jokes have been made about that 
already.

- I'm not bashing python. I probably won't abandon pyhton for a long long 
time.

It just seems that jumping into lisp has a considerable initial investment, 
and I'd like to get an overview of its benefits before I decide whether to 
make that investment myself.

Thank you.

Regards,

Fernando.



More information about the Python-list mailing list