Python vs. Perl, which is better to learn?

Jason Voegele jason at jvoegele.com
Fri May 3 10:42:18 EDT 2002


Chiming in from the Ruby perspective...

Alex Martelli <aleax at aleax.it> wrote in message news:<B3iA8.91514$vF6.2737545 at news2.tin.it>...
> John J. Lee wrote:
> 
> > What differences did you have in mind, between Python and Ruby, that are
> > really significant?  I've always lazily assumed there are none (based on
> > a few minutes scanning of a web page or two).

[snip some good points about Ruby]

> Ruby's closer to Perl in many small details, although, as I understand,
> some are deprecated (in the original sense, i.e., "they're there but we're
> sorry they are"), such as the ability to call functions without parentheses
> in certain cases, or special global variables with strange (non alphameric)
> names.  I guess these shouldn't count as "deep".

You are correct concerning the special global variables ($_ and
friends).  Only long-time Perl hackers are very fond of them.  Even
matz has said that if he re-designed the language from scratch he
would probably leave them out.

On the other hand, the ability to call functions without parentheses
is not so clear-cut.  Some believe that it leads to less readable
code.  Others (such as myself) view it as essential for supporting the
Uniform Access Principle.  Usually I'll leave the parentheses off of a
method call if it takes no arguments, which allows me to switch
between using a variable and using a method more easily.  I also find
it easier to read in such cases.  I find empty parentheses() as you
find in C++, Java, and Python rather ugly (a "call" statement in
disguise, as it were), although at least in Python and C++ they are
actually an overridable operator, whereas in Java they are just
gratuitous syntax.

In addition, I'll leave the parentheses off of function calls that are
conceptually similar to keywords.  For example, Ruby's "raise" method
(which raises an exception), or an "assert" method from a testing
framework, or attr_accessor and friends.

Just my $.02

-- 
Jason Voegele
"We believe that we invent symbols. The truth is that they invent us."
    -- Gene Wolfe, The Shadow of the Torturer



More information about the Python-list mailing list