What's better about Ruby than Python?

Borcis borcis at users.ch
Fri Aug 22 15:10:15 EDT 2003


Andrew Dalke wrote:
> 
> Quantum mechanics is simple.  It's just   H | psi> = E | psi>
> 
> What's H mean?  And psi?  And bra-ket notation?
> 
> The reason my original forays into Lisp around 1990 failed was
> because the documentation I had for learning it didn't talk about
> anything I found interesting, like doing file I/O and graphics.  It
> went on-and-on about data structures and manipulating them.
> 
> My later attempts were by trying to customize my Emacs LISP
> setup, and getting various errors because I didn't know the
> quoting rules well enough.

The only thing I ever did in (X)emacs was a nicely working code animator for 
MOO procedures, actually it was a client-server thing, there was a reversible 
code decorator, and the decoration led the code upon execution by the MOO to 
surround each one of its steps by a handshake with the XEmacs client, that the 
latter converted to an animating transformation of the source code text before 
the user's eyes and control. I was left with the impression that Xemacs (and 
its lisp) were dependable.

> 
> Since then it's been limited to incidental learning, like seeing examples
> and trying to figure them out.  Eg, consider Gabriel's "Worse is
> Better" essay.  The section "Good Lisp Programming is Hard"
> http://www.ai.mit.edu/docs/articles/good-news/subsubsection3.2.2.4.html
> gives this example
> 
> (defun make-matrix (n  m)
>   (let ((matrix ()))
>     (dotimes (i n matrix)
>       (push (make-list m) matrix))))
> 
> (defun add-matrix (m1 m2)
>   (let ((l1 (length m1))
>         (l2 (length m2)))
>     (let ((matrix (make-matrix l1 l2)))
>       (dotimes (i l1 matrix)
>         (dotimes (j l2)
>           (setf (nth i (nth j matrix))
>                 (+ (nth i (nth j m1))
>                    (nth i (nth j m2)))))))))
> 
> and says the above is both "absolutely beautiful, but it adds
> matrices slowly. Therefore it is excellent prototype code and
> lousy production code."

The pythonist can only wonder, before such code, whether the transform 
consisting in replacing all parentheses with zeroes (eg null strings) is 
reversible; and how it could be doctored to be reversible, if it isn't.

On a sideline, shouldn't the "absolute beauty" of the code mean that a
good enough compiler should *understand* well enough its intent
to substitute more appropriate code ? Of course, we would supply the compiler 
simultaneously with the complete layer of methods.

The next step would be to integrate our intelligent compiler in the IDE, so 
that the student having typed the above would be proposed coherent completion 
upon typing " (defun substract-matrix ..." or " (defun multiply-matrix ..." :)

Cheers B





More information about the Python-list mailing list