Why should I switch to Python?

Tim Peters tim_one at email.msn.com
Sat Apr 1 21:54:07 CEST 2000


[Aaron Turner]
> ...
> Basically if you know both languages [Perl & Python], and were planning
> a mid-sized project, why would you choose Python?

When I was very young, I wondered why my dad's electric razor didn't rip his
face to shreds.  As a budding empirical scientist, I tested my theories by
trying it first on my cheek, and then on my tongue.  This was very
educational -- although it's still painful to talk about <wink>.

In other words, "voice of experience".  There aren't a lot of bilingual P
programmers out there, but I expect you'll find the majority of them hanging
out on c.l.py rather than c.l.p.m.  That should tell you the conclusion
you're likely to reach if you decide to become one of them too.  Nobody is
going to argue you into it, though, and Python is easy enough to learn that
there's no significant barrier against just giving it a try.

>From what I've seen-- which matches my own experience --people generally
switch over gradually.  The prime motivation seems to be that, time after
time, when tracking down a bug in a Perl program, you increasingly realize
"hmm -- if I had written this in Python, this wouldn't have happened".
Whether it's the 200th time you've been shredded by an array-vs-scalar
context surprise, or the 12th time an implicit coercion guessed the wrong
way, they're traps you *can't* fall into in Python.

Python's syntax is simpler, its semantics more regular, and its philosophy
of raising exceptions is "gripe whenever there's a reasonable doubt" rather
than "assume the programmer meant whatever they wrote".  These conspire to
make larger Python systems less work over the long haul, and especially in a
team project (TMTOWTDI loses its cowboy charm when you have to decipher 6
other peoples' code every day too).

> It's hard to take my friend seriously in his evaluation when he says
> he'd rather do this project in C++ than in Perl (especially when he
> doesn't know Perl).

Depends on the project.  I make my living these days on a project that's
about a half million lines of C++ and assembler -- Perl and Python are both
too fat and slow to have much use in it apart from automating testing.  Perl
gets used a lot for the latter, but other groups where I work, with large
projects that can afford the fat of either P language, all use Python now,
or Java + JPython.  There's no company policy on this, it's a group-by-group
decision.  And despite that we now have many more lines of Python than Perl,
I still spend most of my "help others debug their scripts" time staring at
Perl.

a-day-of-experience-is-worth-a-decade-of-usenet<wink>-ly y'rs  - tim






More information about the Python-list mailing list