Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Perl tutorial building on Python skills?

by LanX (Sage)
on Oct 19, 2021 at 14:16 UTC ( #11137730=perlquestion: print w/replies, xml ) Need Help??

LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I've been asked to give a Perl crash course to a new colleague, who is supposed to have programming background in Python.

Any recommended materials?

I did a quick search and found this cheat sheet:

Any more?

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

  • Comment on Perl tutorial building on Python skills?

Replies are listed 'Best First'.
Re: Perl tutorial building on Python skills?
by eyepopslikeamosquito (Bishop) on Oct 20, 2021 at 00:51 UTC
Re: Perl tutorial building on Python skills?
by Discipulus (Abbot) on Oct 20, 2021 at 07:41 UTC
    Hello LanX,

    A conversion! Finally :) It will be similar to the Neo escape and awake in Matrix :)

    A quick search shows a python to perl translator.. well is a 2003 project, probably no more useful, but the example in the page can be a start.

    Another one seems very poor quality at first glance (uppercase perl ;).

    By other hand perl-vs-python comparison sheet shows something interesting, notably the sentence Perl provides freedom..

    For the little I know about the snake, I'd pay attention to explain two important differences: python-data-types are different from perl ones and if they are used to work with sets and tuples they should learn how to play with data types in perl.

    The second key difference is scope.

    A read of perl philosopy is surely worth, but if they are already programmers then ModernPerl is the right book.

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      > A read of perl philosophy is surely worth, but if they are already programmers then ModernPerl is the right book.

      Oh yes, strongly agree. Especially given the pupil is already an experienced programmer. chromatic explains why Modern Perl is so short (see also the excellent reply by xdg):

      Modern Perl assumes you're already decent at programming, so it elides some basic stuff in favor of explaining how Perl works from philosophy to programming in the large. Learning Perl assumes you've never programmed before, so it spends more time on the basics, covers less of the language, and doesn't explore the philosophy of Perl in as much detail.

      Modern Perl also tends to be kept more up to date with the latest version of Perl than Programming Perl, say.

      Depending on your pupil, it might also be worth emphasizing the difference between Readability and Maintainability.

      Not sure if you're planning on mentioning TMTOWTDI or TIMTOWTDIBSCINABTE but I noticed when playing code golf that Python often out-TMTOWTDI'ed Perl! :)

      Update: Regular expressions are built into the language in Perl, while in Python they're provided by the re module -- this makes a massive difference in terms of convenience and ease of use, so you'll probably find yourself reaching for a regex solution more often in Perl than Python (especially if you're tybalt89 ;-).

      Another key point that should be carefully explained in your course is Perl's unusual use of context, especially scalar vs list context.

      Further update: Autovivification is yet another Perl quirk -- see "Emulation in other programming languages section" for one way to emulate it in Python. See also: Re^2: Honest question about Perl, Python and Ruby, which shows how I emulated it in Ruby.

        I had planed on making much the same argument for "Perl Best Practices". I have now decided that for this purpose, it is little more than an expansion of 'Modern Perl's chapter on "Perl Beyond Syntax". I continue to recommend the Preface of "Perl Best Practices" for its discussion of the goals of "best practice".
        Bill
        Thanks!

        > chromatic explains why Modern Perl is so short (see also the excellent reply by xdg):

        Actually the second chapter in Object Oriented Perl (which xdg is dissing) includes a very good overview of (non-OO) Perl in 60+ pages.

        Damian is a brilliant author and it's a good base for an experienced programmer. (Plus I have the German translation which makes communication easier)

        Modern Perl then is larger and goes more into details and is already available in their office in Berlin.

        This should give a very good foundation to build on.

        Then later combined with my own self assessment quiz plus links into the docs, should clarify remaining issues.

        (I don't want to start learning Python in deep for this :)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

        ) RFC: Self Assessment Perl

Re: Perl tutorial building on Python skills?
by soonix (Canon) on Oct 20, 2021 at 10:40 UTC
    I don't have materials of my own, but some points: especially with a Python background, some of the differences stand out:
    • context is a concept unique to Perl, and explained very good in the corresponding chapter of chromatic's book
    • Python has an explicit Boolean data type, Perl has a boolean context
    • Python regular expressions are strings, hence different quoting, and "PCRE" are not 100% "PC".
    • last but not least: as Python only has lexical scope, it was difficult for me to understand dynamic scopes, and although there is overlap between Perl's local and computer science's local, they are not the same.
      Thanks for the valuable input of all of you , didn't have the time to reply in detail yet.

      I have to wait to meet the new colleague to assess which kind of programming/python skills be already has.

      After all Python is the new Basic, everyone claims he knows it. I don't wanna end up explaining Python to him or giving a class in language design...;)

      > "PCRE" are not 100% "PC".

      Minor nitpick. PCRE is also the name of an RE engine used by several products including PHP. Python has its own RE engine, trying to be PC

      > Differences

      More:

      • function signatures
      • Most (all?) variables are references
      • strings are immutable
      • regex are first class objects in Perl
      • list flattening/interpolation in Perl

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Re: Perl tutorial building on Python skills?
by perlfan (Vicar) on Oct 19, 2021 at 17:47 UTC
    It might require some unlearning or deprogramming. I've had success in the past with someone experienced in another language, and just going through with them in a manner that has them come up with a programming task (or idiom.) in the their strong language; then showing them the Perl idiom. General concepts about dynamic languages in your case sounds like it should not be a barrier. This relies on them being proficient with another language (here Python); and the stronger the better.

    Another thing that comes to mind that might be helpful is, Rosetta Code.

      Thanks, I have some experience in Perl training, but I'm supposed to "crash teach" him via video conferencing.

      So I was hoping for some overview which helps me understanding which points to address.

      I wouldn't call me a python expert, tho I'm often surprised what self proclaimed python experts don't know...

      It would be easier if it was JavaScript, I have that tutorial already ready in my mind...

      Update

      Ha! there is plenty of such material for JS I could built on this.... :)

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        LanX:

        It would be easier if it was JavaScript, I have that tutorial already ready in my mind...

        In the vein of the traditional Mathematician's answer, then, first do a "JavaScript for Python Programmers" bit, and then proceed from there!

        </s>

        ...roboticus

        When your only tool is a hammer, all problems look like your thumb.

Re: Perl tutorial building on Python skills?
by Bod (Curate) on Oct 20, 2021 at 00:03 UTC

    I have no information to help you - sorry...

    But it's exactly the sort of 'crash course' I could well be needing sometime soon-ish. We are hiring and many of the applicants have Python experience supposedly.
    So, if you find something ready made that's helpful, or you create some ideas, I would be very grateful if you could share them please!

Re: Perl tutorial building on Python skills?
by pritesh_ugrankar (Monk) on Oct 20, 2021 at 16:46 UTC

    Hi,

    Whatever be the level of the python programmer's expertise, I would strongly suggest he get a copy of Ovid's Beginning Perl. It was released in 2012, but it is still quite relevant. He might find the first few chapters "Meh", but chapter 6 onwards, the book starts getting into some real interesting stuff Perl offers. Chapter 7 (subroutines) is truly worth for someone who comes for another language, and that's just the beginning. The book is dense but if he goes through it, he'll learn enough to write amazing code, avoid pitfalls, be amazed by what Perl Testing has to offer and so on...

Re: Perl tutorial building on Python skills? (pleac)
by Anonymous Monk on Oct 20, 2021 at 08:06 UTC
Re: Perl tutorial building on Python skills?
by Anonymous Monk on Oct 22, 2021 at 05:26 UTC
    Well, this might seem a bit basic, but Learning Perl does clearly explain the basics of Perl types etc and an experienced programmer would be able to rip through that and occasionally refer back to it for details.
    The other one to jump-start idioms etc is the Perl Cookbook, even if some of it is a bit old now ie some of the techniques you would now use a module.
    However it clearly shows examples of Perl in more realistic action; I've always found it handy for ideas to build on
    YMMV

    Cheers
    Chris

      ++ for the Perl Cookbook. The learner should be able to recognise and code up solutions to the scenarios in their own language and then compare/contrast with the idiomatic Perl solutions. That ought to be a quick way to get them up to speed and starting to think more in the Perl worldview. Great suggestion.


      🦛

        How could the Perl Cookbook be brought up to date in an open source fashion?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11137730]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2022-05-22 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (78 votes). Check out past polls.

    Notices?