views:

290

answers:

3

I'm learning Python (and it's my first programming language so don't be too intense with your reasons) and I wanted to know how it stacks up to other scripting languages, like Perl and Ruby. What is Python better in comparison to other scripting languages, and what is it worse for?

+2  A: 

Hi Yrsnkd,

Here is a nice overview of why Python (the language) is a very nice place to start programming: http://www.python.org/about/

Python includes a very comprehensive standard library (i.e. "batteries included") which allows you to solve many programming problems.

Once you've learned Python, I'd suggest you also learn other languages such as Ruby, because different languages provide different paradigms for thinking about programming, thus expanding your knowledge of models of computation.

Joubert Nel
+1: Link to the python site.
S.Lott
+1: Not dissing other languages without factual basis (like vast majority of answer of question like this end up doing).
DVK
+9  A: 

First off, an advice - look for POSITIVE things said from opposite sides. Meaning, you should trust positive things said about Perl by Python-related sources (or positive things said about Python by Perl related sources) much more than the opposite.

The two reasons are that:

1) People who have reason to like Python would NOT be inclined to say good things about Perl unless they were truly trying to be objective (which is what you ideally want). And vice versa - it's a problem with human biases and motivations, NOT with either Perl or Python.

2) People writing such comparisons favoring one language are VERY often completely mis-informed and not very practiced about the one they are unfavorable about. As evidence see this article: http://python.about.com/od/gettingstarted/ss/whatispython_5.htm - pretty much anything it has to say about Perl is, to put it gently and mildly, a comlpete and utter bunk. I'm sure there are equally moronic Python put-downs from Perl fans, I just never read enough about Python to be able to think one up off the top of my head.


Second, please be aware that, at least for Perl - and I strongly suspect, for Ruby and Python - the moniker of "scripting" language is not really applicable anymore.

Yes, their (especially Perl's) origins are somewhat connected to shell scripting, and yes, a small subset of the languages capabilities can be - and are - used to write shell scripts, and make that small task very easy and extremely productive.

However, at this point in its long history, Perl is in no way even remotely restricted to those capabilities, and is used for developing anything from scripts to web frameworks to servers to large scale enterprise software to bio-informatics software.


Third, please look at this - it has a lot of links:

http://wiki.python.org/moin/LanguageComparisons

DVK
And, for a prime example of point #2, look at Paul Nathan's answer. At least SOME of his comparisons are comparing based on some archaic features of Perl that were not true for the last couple of years (un-robust OO, lack of exceptions, lack of web frameworks) and some that are just not real metrics (bigger set of "core" modules)
DVK
@DVK: Disagree. Languages are not libraries.
Paul Nathan
@Paul - I'm sorry but your comment is 100% true (languages are NOT libraries) and yet 100% supports my view. You answered a request to compare two languages by comparing not even merely avialable library sets - which is actually a valid enough metrics if you explain the proper context - but by comparing the volume of libraries **pre-packaged into ONE of the distributions** (as an example, Strawberry Perl prepackages a lot of CPAN, so do a vast majority of corporate Perl installs).
DVK
@DVK: I didn't pick any Perl distribution out? I was thinking of the Core Modules on perldoc.perl.org... anyway didn't intend this to be a big shout-out about Perl.
Paul Nathan
Perl fans are usually were reasonable - toleration for other languages is in Perl culture.
Alexandr Ciornii
@Alexander: <smug><nose upturned>We can afford to be, since our language is so much superior</nose upturned></smug> **DVK runs away from Paul Graham's wrath, stumbles upon a copy of "On Lisp" book and trips up** :))))
DVK
+5  A: 

I'm learning Python (and it's my first programming language so don't be too intense with your reasons) and I wanted to know how it stacks up to other scripting languages, like Perl and Ruby. What is Python better in comparison to other scripting languages, and what is it worse for?

IMO.

I have tried Python 2.x for some time and went back to the Perl and C++.

What is good about Python. Python features better portability and has modern GUI libraries. Standard library in some places is also very very nice (I esp. liked random). Execution speed of arithmetic expressions beats that of Perl.

What is bad about Python. Poor documentation. No warnings, no typing whatsoever combined with weak typing/language's dynamic nature is a hell. Learning easy - using hard, mainly due to immature optimizer driving the need to think about performance edge cases quite early in the development cycle. (That some times reminded me of the Pascal.) OO is a mess at the moment: distinct features and differences between old-style and new-style classes are not spelled out very well; libraries do not mention what type of classes they do define.

Poor documentation probably should be highlighted. There are piles of standard functions but their purpose in life isn't really specified nor decent examples are given. And better half of those standard functions in Perl land would have been sitting somewhere in the perldoc perlguts. Anyhow, looking up stuff is much faster with Google.

Lack of warnings and lack of typing (and that compared to the weak Perl's use warnings/use strict and sub prototypes) is what in the end drove me back. Partially it is because that I write code faster than I can read it thus I like to rely on the compiler/interpreter to tell me where I might have wrote something I haven't really meant.

Also excuse me, but I would throw that at Python again: using indentation to denote code structure is kind'a kinky. I do not mind it per se and for short functions it is very nice. But after one week I have found that I do read Python code slower (compared to C++ or Perl) in greater part because I have to always extra check whether the statement really closed or it still goes on. If code doesn't fit one screen, it becomes a chore to always press PgDown/PgUp just to check. Never before I were that appreciative of the {}s.

All considered, Python is at the moment a mess. Worthy contender I do keep an eye on, but not mature enough for my daily needs. If I were making decision about learning Python now, I would have instead waited for Python 3.x to mature. Many things one would learn now with Python 2.x might be useless in Python 3.x. And Python 3.x is at the moment isn't very useful since many libraries were not yet ported to it.

P.S. Most bogus part I have encountered is the function pointers. I have discovered them sooner than I needed them by writing start_time = time.time and time_elapsed = time.time() - start_time. Half hour later when script finished instead of results I was presented with nice interpreter exception telling me that I cannot subtract function object. And the half hour was due to the standard for loop, as tutorials have taught me. Optimizations I have looked up later (range vs. xrange, manual loop unrolling) made the script run in less than one minute.

Dummy00001