26

Coming from a Perl 5 background, what are the advantages of moving to Perl 6 or Python?

brian d foy
  • 129,424
  • 31
  • 207
  • 592
raldi
  • 21,344
  • 33
  • 76
  • 86

8 Answers8

25

There is no advantage to be gained by switching from Perl to Python. There is also no advantage to be gained by switching from Python to Perl. They are both equally capable. Choose your tools based on what you know and the problem you are trying to solve rather than on some sort of notion that one is somehow inherently better than the other.

The only real advantage is if you are switching from a language you don't know to a language you do know, in which case your productivity will likely go up.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • 2
    You say, "Choose your tools based on what you know and the problem you are trying to solve", but at the moment, I know neither language, and I don't know which aspects of the problem I'm trying to solve are suited by which language. That's basically why I asked the question. – raldi Sep 24 '08 at 14:32
  • @raldi - Perl 6 isn't that much different from Perl 5, so you know most of one language. And from what I see, Python's not even THAT different from Perl 5, and much Perl knowledge will carry over into Python. – Chris Lutz Mar 05 '09 at 04:42
  • 1
    None of this adds any information that helps the questioner (and me) decide either way. It's a pretty vacuous answer. – reinierpost Dec 18 '10 at 18:16
14

Python does not have Junctions. In fact I think only Perl has Junctions so far. :-)

pi.
  • 21,112
  • 8
  • 38
  • 59
  • I, and others, have created "junctions" for Python, just not named it as such, where you can do stuff like: al= [1, 2, 3, 4]; al1= All(al) + 1; if Any(al) > 3: print "some true". – tzot Sep 24 '08 at 08:30
  • 4
    Junctions in Perl 6 can do much more than that. Can your junctions autothread? – Leon Timmermans Sep 24 '08 at 12:11
  • No, not mine. Is junction autothreading already improving the speed of your programs? If yes, by what factor? – tzot Sep 26 '08 at 09:56
  • 4
    Junctions are not primarily about speed, but about readability. – moritz Oct 13 '08 at 11:16
11

In my opinion, Python's syntax is much cleaner, simpler, and consistent. You can define nested data structures the same everywhere, whether you plan to pass them to a function (or return them from one) or use them directly. I like Perl a lot, but as soon as I learned enough Python to "get" it, I never turned back.

In my experience, random snippets of Python tend to be more readable than random snippets of Perl. The difference really comes down to the culture around each language, where Perl users often appreciate cleverness while Python users more often prefer clarity. That's not to say you can't have clear Perl or devious Python, but those are much less common.

Both are fine languages and solve many of the same problems. I personally lean toward Python, if for no other reason in that it seems to be gaining momentum while Perl seems to be losing users to Python and Ruby.

Note the abundance of weasel words in the above. Honestly, it's really going to come down to personal preference.

Kirk Strauser
  • 30,189
  • 5
  • 49
  • 65
  • Your answer probably belongs to the opposite question; this question provides a link. – tzot Sep 24 '08 at 08:25
  • 6
    the problem is random snippets of Python sometimes don't work because where they were pasted didn't preserve the whitespace correctly – MkV Oct 31 '10 at 15:38
  • 1
    If Python is more consistent, then why is array indexing a separate syntax? Why are list comprehensions different to most other code? Why are lambdas limited to one line of code, which requires different syntax to what you might otherwise write? Also the question was about Perl6, which is now known as Raku. In Raku all of those I talked about earlier use the exact same syntax. It is a common trope to say that Raku is strangely consistent. Mainly because it is consistent both at a surface level, but also in deep fundamental ways that most languages aren't (including Python). – Brad Gilbert May 06 '21 at 13:57
8

Perl is generally better than python for quick one liners, especially involve text/regular expressions
http://novosial.org/perl/one-liner/

Peter N. Steinmetz
  • 1,252
  • 1
  • 15
  • 23
Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
6

Python has one huge advantage: it's implemented, there's a rather stable compiler for it.

Perl 6 (renamed Raku in 2019) is a rather visionary language, with a stable compiler and test specification released in 2015. It has a set of very cool features, among them: junctions, grammars (yes, you can write full parsers with Raku "regexes"), unicode handling at the grapheme level, and lazy lists.

In your particular case when you know Perl 5 you'll get familiar with the Raku (née Perl 6) syntax very quickly.

For a more comprehensive list of what cool features Raku has, see https://raku.org/ or alternatively, the FAQ.

jubilatious1
  • 1,999
  • 10
  • 18
moritz
  • 12,710
  • 1
  • 41
  • 63
5

Python has a major advantage of being available in a production-ready format today.

Python has Jython and IronPython, if you need to work closely with Java or the .net clr.

Perl 6 has the advantages of being based on the same principles as Perl (1-5); If you like Perl, you'll like Perl 6 for the same reasons. (There's more than one way to do it, etc.)

Perl 6 also has an advantage of being only partially implemented: If you want to hack on language internals or help to define the standard libraries, this is a great time to get started in Perl 6.

Edit: (2011) It's still a great time to hack on the Perl6 internals, but there is now a much more mature, usable Perl6 distribution, Rakudo Star. If you want to use Perl6 today, that's a great choice.

Sean McMillan
  • 10,058
  • 6
  • 55
  • 65
  • One field where Python is better than Perl family is abundance of powerful plotting, data analysis and machine learning libraries in Python. Perl family well lags behind. Other than these, both are good. – Suman Khanal Mar 14 '17 at 14:33
4

You have not said why you want to move away from Perl*. If my crystal ball is functioning today then it is because you do not fully know the language and so it frustrates you.

Stick with Perl and study the language well. If you do then one day you will be a guru and know why your question is irrelevant. Enlightment comes to those to seek it.

  • You called it "Perl5" but there is no such language. :P
Mr. Muskrat
  • 22,772
  • 3
  • 20
  • 21
  • 1
    I consider Perl5 to be a language. I'm a Fiver! :D – skiphoppy Oct 03 '08 at 16:28
  • 2
    Perl 5.10 is out, but you said Perl 5 doesn't exist? – Brad Gilbert Aug 05 '09 at 21:52
  • 3
    On the contrary, there are a lot of people on PerlMonks and in the Enlightened Perl Organzation's "Perl Iron Man Challenge" who both consider Perl5 to be a language and Perl6 to be a *different* (but related) language. I read the question not as "I want to get away from Perl", but rather as "I believe that Perl5 is about to go away, so where should I go when that happens?", in which case the correct answer is really "Perl5 isn't going away any time soon, so don't worry about it." – Dave Sherohman Aug 05 '09 at 23:12
  • I never said that Perl 5 does not exist. I simply do not consider the current incantation of Perl "Perl5". If Larry wanted it called that, he would named it that. :P – Mr. Muskrat Aug 06 '09 at 18:39
4

IMO python's regexing, esp. when you try to represent something like perl's /e operator as in s/whatever/somethingelse/e, becomes quite slow. So in doubt, you may need to stay with Perl5 :-)

user502515
  • 4,346
  • 24
  • 20