Migrating to perl?

Martijn Faassen m.faassen at vet.uu.nl
Thu Jan 4 22:33:21 EST 2001


Joel Ricker <joejava at dragonat.net> wrote:
[snip]
> So basically what I'd like to know is, how do the two compare?  Is there an
> easier learning curve with Python?

>From my experience, yes; a couple of years ago I tried to learn Perl for
some days, and I kept getting lost in all the syntax options and other
things that didn't mesh well with my mind. Then I learned Python right
away without much difficulty at all, it just clicked.

> Are the modules and add-ons as good as
> perl (ie, Database -- I'm primarily interested in MySQL, CGI, Graphics).

While from reports perl's modules support (esp. CPAN) is still better
than Python's in some ways (there's more of it, and they're easier to
install), I've never had any trouble with Python. Check out the vaults of
Parnassus for a catalog of modules:

http://www.vex.net/parnassus

I've done databases with Python (mostly Access through ODBC and Postgresql,
but MySQL is supported as well), and CGI's fine too (though I mostly
use Zope: http://www.zope.org), and there are lots of bindings to graphics
and UI toolkits, depending on what you like. I've been toying with
pygame recently, which is pretty low level, though (http://pygame.seul.org).

> What about OOP?  Is it it a full OO language? 

Yes, Python does OOP just fine, and is a full dynamically typed OOP language.
If you are familiar with languages like C++ or Java you're in for a 
hopefully pleasant surprise; there is much less programmer overhead to
create and use classes than there is in those languages, due to the
simpler syntax, and dynamic typing instead of static typing.

> Is it easier than to use than
> perl?  Perl OO just feels like it has been cludged together.

>From my limited experience with Perl, definitely yes. I've been told Perl's
OO model is actually inspired by Python's, but I didn't spend enough of time
with Perl's OO features to know much about that.

In python this is how you make a class:

class Foo:
    def __init__(self):
        """Functions that start and end with __ are special, and this one
        is used to initialize (construct) objects in whatever way you
        like."""
        self.text = "this is some text"
        self.number = 15

    def get_text(self):
        return self.text

    def add_to_number(self, amount):
        self.number = self.number + amount # or self.number += amount

# now let's create an object of class Foo
myfoo = Foo()

# and use the methods
myfoo.add_to_number(40)
print myfoo.get_text()

> And lastly, what about the Python community?  Is it friendlier than the perl
> community?

The Python community's reputation is that it's friendlier than the Perl 
community, the flame war about variable initialization in the do..until
thread notwithstanding. :)

>  Too many times I've asked questions and all I'll get is pointers
> to documentation, which I've already read and so thats why I'm asking for
> information in the first place.  I understand simple questions for basic or
> novice information will warrant answers like that but not the things I've
> asked.

I've seen people beinn pleasantly surprised by the quality of answers they've
received in this newsgroup, so you may like it.

Good luck!

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list