No subject


Thu Nov 16 16:52:29 CST 2006


rather than sin(a) will be enough to make most people stay away from
numerical python.  I say this from experience: most of what Python
does well, guile also did well.  After the IDAE BoF at the 1996 ADASS
meeting, we considered whether guile would be a better platform than
Python.  It had a lot of development force behind it, had all the
needed features, etc.  We asked our audience whether they would use a
lisp-based language.  There was laughter.  The CS people here know
that lisp is a "beautiful" language.  But nobody uses it, because the
syntax is so different from the normal flow of human thought.  It is
written to make writing an interpreter for it easy, not to be easy to
learn and use.  I've tried it about 8 times and have given up.
Apparently others agree, as guile has been ripped out of many
applications, such as Gimp, or at least augmented as an extension
language by perl or python, which now get most of the new code.
Normal people don't want to warp their brains in order to code.

Consider the following:

math:
            2      1/2
    -b +- (b - 4ac)
x =3D ------------------
          2a

IDL:

x =3D (-b + [1.,-1] * sqrt(b*b-4*a*c)) / (2*a)

lisp:

(let x (/=20
          (+
             (- b)
             (sqrt (-=20
                      (* b b)=20
                      (* 4 a c))))
          (* 2 a)))

You can verify that you have coded the IDL correctly at a glance.  The
lisp takes longer, even if you're a good lisp programmer.  Now
consider the following common astronomical equation:

           sin(dec) - sin(alt) sin(lat)
cos(a)   =3D ----------------------------
                cos(alt) cos(lat)

IDL:

a =3D acos((sin(dec) - sin(alt) * sin(lat)) / (cos(alt)*=B7cos(lat)))

proposal:

a =3D ((dec.Sin - alt.Sin * lat.Sin) / (alt.Cos * lat.Cos)).Acos

readable, but we start to see the problem with the moved .Acos.  Now
try this:

         2
      sin x + cos(tan(x + sin(x)))
a =3D e

a =3D exp((sin(x))^2 + cos(tan(x + sin(x))))

a =3D (x.Sin**2 + (x + x.Sin).tan.cos).Exp

Half of it you read from left to right.  The other half from right to
left.  Again, the IDL is much easier to write and to read, given that
we started from traditional math notation.  In the proposal version,
it's easy to overlook that this is an exponential.

So, I don't object to making functions into methods, but if there's
even a hint of deprecating the traditional functional notation, that
will relegate us to oblivion.  If you don't believe it still, take the
last equation to a few non-CS types and ask them whether they would
consider using a language that required coding math in the proposed
manner versus in the standard manner.  Then consider how much time it
would take to port your existing code to this new syntax, and verify
that you didn't misplace a paren or sign along the way.

A statement that traditional functional notation is guarranteed always
to be part of Numeric should be in the PEP.  Even calling it syntactic
sugar is dangerous.  It is the fundamental thing, and the methods are
sugar for the CS types out there.

--jh--




More information about the Numpy-discussion mailing list