Perl or Python ?
Whats its best to learn, Pear or Python ?
|
This topic is subjective and argumentative. The only solution to your problem, is to learn both and then find the one best suited for yourself.
|
Quote:
Python is deliberately more terse, requires a specific type of indentation, and has no way of indicating the end of a function. If you want ultimate flexibility at the cost of having to spend more time choosing which method you want to use to solve a problem, use Perl. If you are more interested in solving problems quickly and don't mind being forced to write your code in a specific style, use Python. |
The difference is that Perl has in it much more from functional programming paradigm ( http://en.wikipedia.org/wiki/Functional_programming ). Python is slowly catching up (i.e. Python 3.* vs Python 2.*).
I find the functional features quite convenient. This may sound odd, but in order to appreciate Perl read on Higher Order Perl: http://hop.perl.plover.com/ . |
I'm learning both. I'd like to say "know", but as it is, there's so very much I don't master yet (in both languages) even though I do get results and have built up scripts/programs that are hundreds of lines long. The thing is, neither was very difficult to learn and neither took long to learn to use. Pros: I can now work with either of them, depending on which one I have available or want to use or suits better for the given situation. Cons: knowing only one would probably have been sufficient, so I've "thrown away" some time by learning both. Not a con really.
In short, learn both of them. You're not going to lose anything. Instead if you only learn either one, but not both, you very probably will be haunted by the thought "was this really the best choice?" for the rest of your life, or up to the point where you do learn the other as well. Next question you're going to ask is "should I learn Python 2 or Python 3, or Perl 5 or Perl 6?". Answer: all of them :) |
Quote:
And the main developer wrote that strict typing, when used, makes the code slower though conceptually it should enable faster code. So, my intent to learn OCaml instead of Perl 6 steadily grows; Perl 5 is still my favorite language at the moment. |
Quote:
of statements and expressions. As with natural languages (English, Greek, Persian, etc), it is much harder to learn to speak and write the language than it is to hear and read that same language. As you read, you'll find that either Perl or Python suits your personal style. Cheers, ~~~ 0;-Dan |
Quote:
Quote:
|
Quote:
|
I am in the learn as much as you can group, although as pointed out in earlier posts this can make it difficult to become a guru in any language
quickly. I agree with Dan's post too that most languages use a commonish ground work (not trying to start a flame here) so to this end you can also look at it that if you become accomplished in one language it will generally be less of an arduous task to learn another. |
Quote:
What can Ruby do Perl can't ? I mean not only built-in functions, but things like closures, anonymity, scoping rules and the like. ... I've been looking closely at Perl6 because I want a language which allows both loose and strict typing - Perl6 allows. It looks like I'll look for strict typing in OCaml, and will still be using Perl5 for loosely typed programs. |
Quote:
|
Quote:
An example out of the many, see this FAQ for Perl to count substrings. True to Perl's mantra, there are a few ways to do it as stated in the FAQ. With Python, there is only one obvious way (note the word obvious), Code:
>>> string = "ThisXlineXhasXsomeXx'sXinXit" Code:
open FILE, '<', "foo.txt" or die "Can't open: $!"; Code:
open('foo.txt') you really have no reason to argue with me on this point of "more than one ways in Perl vs that in Python", if you have used Python long enough as you had used Perl. |
Quote:
So, conceptually there is a 'split' way to split a string and a regular expression way to split a string - both way are present in both langauges. So, as I said, there is more than one way to do it. |
Quote:
|
Quote:
I am too lazy, but if to dig deeper, I'm sure I'll find in Python "there is more than one way to do it" in many more places. |
Quote:
tell me which one to you is obvious in these Perl statements (and don't try to evade this question as well). Code:
open FILE, '<', "foo.txt" or die "Can't open: $!"; Code:
if ( .... ) { Code:
if something : Sure you can find one of two Python's "more than one way to do it" , but when it comes to how many there are, Perl beats Python all the way. |
I suggest learning both. I haven't really tried Ruby much, maybe it's good. You can learn it too if you like.
And I agree with Sergei Steshenko's comment that you should read "Higher Order Perl" to really understand what it's all about. |
Quote:
Quote:
Quote:
|
Quote:
Quote:
don't give comments that are half truth and leave people guessing what it means next time. Nevertheless, you still didn't explain the "no way of indicating end function" statement. |
Quote:
Code:
#!/usr/bin/python Code:
Starting the function... |
Quote:
I guess everybody is different. If you have used Python for years and still couldn't get used to its style, then its not for you. |
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
http://utcc.utoronto.ca/~cks/space/b...honIndentation . At all, if I understand it correctly, the indentation may be whatever number of spaces, just returning to previous level of indentation must have the same number of spaces, i.e. Code:
foo_indent_level Here is a thread about an indentation error: http://bytes.com/topic/python/answer...nt-comphrehend - though the thread is not about 'break', I find the code unreadable because of the way 'break' (line #36, #39) is indented. And, if I understand it correctly, there is more than one way to select indentation of 'break'. |
Quote:
if you write it in Perl with good coding practice, Code:
foo_indent_level1{ Code:
foo_indent_level2{ Which one would you prefer ? A good Perl programmer would want to re-indent it nicely anyway. |
Quote:
I indent this way: Code:
if(...) Regarding "there is more than one way to do it" - just everything in programming after the Turing machine proves that there is more than one way to do it. |
Quote:
Quote:
I can't help it you don't see it that way, because that's your business and i can't be bothered. |
Quote:
|
Quote:
|
Quote:
TIMTOWTDI is good since you can have more choice, BUT will lead to inconsistencies and sometimes problems that can be solved in the most obvious way become messy and obfuscated. This will happen in any language that follows this philosophy, not just Perl. |
Quote:
http://www.ibiblio.org/g2swap/byteof.../for-loop.html http://floppsie.comp.glam.ac.uk/Glam...ipting/19.html - both 'for' and 'while' loops exist, though conceptually only 'while' loop is necessary. |
Quote:
There should be one-- and preferably only one --obvious way to do it.. Read it carefully. If you don't understand English, look up the dictionary or thesaurus. Quote:
Let me fill you in if you are still clueless. Can you please look at my argument again on why Perl encourages inconsistencies. See post #17. I can find you some more in perlsyn: different ways to write for loops in Perl Code:
for ($i = 1; $i < 10; $i++){ } Code:
for ( ... ) in ( ... ): My illustrations support my point that TIMTOWTDI is good sometimes, as you can see from the Perl's different for loop syntaxes that programmers can have choices. But because of this, code is inconsistent. Lastly, its not just Perl , but any other languages with TIMTOWTDI philosophy will encounter this "issue". You may disagree for all i care, but that's how it is Its just one of my observation with regard to "TIMTOWTDI" after using Perl and Python for so many years. You don't have to really get so heat up with me about this. Now, can we stop? |
Quote:
... Look into C++ 'boost' library - IIRC they've implemented FOREACH a-la Perl - because people like it. I.e. people like to be able not to deal with numeric index while iterating over array. At all, look at other than Perl/Python languages - and then you will see that Perl simply borrowed a lot of ideas from them. For example, 'maxima' has a notion of current expression/variable: Code:
__ is the input expression currently being evaluated. That is, while an input expression expr is being evaluated, __ is expr. |
All times are GMT -5. The time now is 04:19 PM. |