What's better about Ruby than Python?

Andrew Dalke adalke at mindspring.com
Tue Aug 19 19:30:15 EDT 2003


Alexander Schmolck:
> One thing that makes such an attempt fairly unattractive for anyone with
> finite amounts of time is that python isn't that much use without its
> supporting C/C++ modules schemes/lisps suck in the FFI department (every
> lisp/scheme has its own way of interfacing to C).

If Parrot gets enough Python working for the challenge, then someone
could write a Lisp-y language targeting Parrot, and take advantage
of the work of others.

For that matter, there's Lisps on the JVM, no?  Could support
Jython.

> Could you say a little bit more about it? In python I think one could to
some
> extent use operator overloading and a special expression class, that
> simplifies the literal expression the programmer stated, but I guess then
one
> would then to explicitly request evaluation (and operator overloading
isn't
> quite powerful enough to easily incorporate 'alien' class-instances, too).
>
> Is the C++ code something along those lines, or different?

Different.  The problem with the operator overloading approach is
the creation and description of intermediate objects.  If you do

a = b + c * d

then  "c*d" makes an intermediary temporary.

Template expressions solve it by providing a description of
how to do the add, early enough that the compiler can optimize
based on the whole express.  Eg, for vectors, the compiler
could generate code equivalent to

  for (i=0; i<n; i++) {
    a[i] = b[i] + c*d[i];
 }

Here's an old reference
  http://infm.cineca.it/infm_help/parallel/poop/KAY.html

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list