[R] Statistical computing... Perl, Python, Octave, GAP

Chunlou Yung chunlou at yahoo.com
Mon Mar 31 19:51:12 CEST 2003

My two cents on Perl and Python (and stuff) :)....

Perl was designed to be "easy" to use but not necessarily the easiest thing
to learn (it's not hard to get started, nonetheless; just perhaps a bit hard
to master), while Python was designed to be "obvious" to learn and write and
read. Perl to scripting language is like C/C++ to compiled language, whereas
Python akin to Java (my feeling anyway). Let me elaborate...

Library Size: As far as I know, Perl has twice as large a library of modules
(about 4000) as Python, though both are certainly continuing to grow. (Like,
you're probably not going to write your own XML parser.) Don't expect
anything in advanced math in either one (why would you? You have R). As for
DB support, both are strong in that regard.

Bioinformatics: There're also vast volume of codes written in Perl and
Python in bioinformatics (freely) available on this planet, just so you
know--save yourself some time.

Capability: If you must write some code on your own, as opposed to stealing
it from someone else, Perl and Python both can do a good job, as far as
"data cleaning" (be prepared to learn regular expression, though), or task
automation goes. But...

Flexibility/Readability: Perl is a ridiculously flexible language.
Generally, it's a good thing for an individual programmer, since he can do
things however he wants but an issue for a team of programmers and a
headache for a project manager, as it's rather hard to impose consistency in
the way people code because there're so many ways to do it in Perl.

So a side effect of Perl's flexibility is its readability. Python (like
Java) tends to be more readable--maybe except for Python's "print" statement

Speed: Benchmarks generally place Perl faster than Python. But for small
jobs, their speed difference doesn't matter much. Besides, speed probably
depends more on how you write your code than what you write it in.

OOP: If you're going to program extensively, sooner or later, you'll
probably run into OOP. Python's implementation of OOP is pretty natural
(especially if you come from Java or something) and it's easy to understand.
Perl has its own unique implementation of OOP--if you're a Perl guy/gal, its
implementation is brilliant; if not, it's absolutely, utterly queer--like,
for one thing, you could have both procedural codes and OOP codes in same
Perl's module (this flexibility doesn't mean you should do it--probably few
people do, as it will inadvertantly lead to confusion). (But then, S also
has its own implementation of OOP.)

Basically, Perl is a procedural language that can do OOP in its own weird
way; Python is a OOP language that can pretend to be a procedural language.

GUI: If you need to write a GUI, you could do it in Perl or Python (or TCL
as well, yet another scripting language), not that you should--it's slow and
clumsy. VB or Java would be a better choice--they're still slow but not as
clumsy. If you need speed, perhaps C++ is your only choice. Web-based GUI
would be an option, as long as you don't inadvertantly expose your company's
secret to your competitors via the Web.

Survival: If you're concerned about whether Perl or Python would ever go out
of business, my prediction is, they won't. Python is a continuous rising
star, continuously luring users away from Perl and capturing many newcomers,
who prefers a cleaner language. But Perl is not going to extinct, just as C
is not going to die any time soon. Geeks tend to like Perl; most other
normal human beings found Python just fine.

Support Group: Both Perl and Python have excellent support groups. If you're
not too antisocial, you should have no problem to find help from total
strangers over the Web for most of your daily problems (programming or


By the way, if by any chance you need something that can do matrix/numerical
computation very, very fast, Octave is a good product too. It's free. It's
as fast as Matlab, faster than R, but slower than C.

And if on some rare (or weird) occasions, you need to do some computatonal
group theory stuff, GAP (Groups, Algorithms and Programming) is for you.
It's free too. (You can find it at http://www.gap-system.org)

Hope it helps.


More information about the R-help mailing list