Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Get me excited about perl

by jatill (Beadle)
on Sep 19, 2012 at 18:13 UTC ( [id://994491]=perlquestion: print w/replies, xml ) Need Help??

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

I have been charged with giving a presentation called "Get me excited about perl" to a bunch of non-perl programmers. What features / modules / concepts should I cover that will people really interested in wanting to use perl?

Replies are listed 'Best First'.
Re: Get me excited about perl
by BrowserUk (Patriarch) on Sep 19, 2012 at 19:55 UTC

    Show them Perl's greatest asset -- concise solutions to everyday problems.

    If you have time, pick some task that will resonate with as many of them as possible and get one or more of them to solve the chosen task in their favoured langugages before the day.

    By way of example (because the examples already exist): frequency count the words in a text file.

    And then write & run your perl solution in real time:

    perl -nle"y/a-zA-Z/ /cs; ++$h{$_} for split }{ print qq[$_:$h{$_}] for + sort keys %h" theFile break:1 brief:1 bring:3 brought:2 buffalo:16 burden:1 but:20 by:16 call:2 called:6 came:2 campaign:1 can:36 cannot:2 capable:1 capitals:1 career:2 cart:1 case:2 ...

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

      php -R 'foreach (str_word_count(strtolower($argn), 1) as $w) $h[$w]++;' -E 'ksort($h); foreach ($h as $w=>$c) print "$w:$c\n";' <theFile

      Update: it's sorted now.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

        Is the output sorted?


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        RIP Neil Armstrong

        tobyink,

        Okay, what's the joke?

        You brought 'php' to a thread on 'Get me excited about perl'!

        I can always use a good laugh...Ed

        "Well done is better than well said." - Benjamin Franklin

Re: Get me excited about perl
by davido (Cardinal) on Sep 19, 2012 at 21:44 UTC

    An excerpt from Higher Order Perl:

    3.11          

    If you’re trying to explain to a C programmer why Perl is good, automatic memoization makes a wonderful example. Almost all programmers are familiar with caching techniques. Even if they don’t use any caching techniques in their own programs, they are certainly familiar with the concept, from caching in web browsers, in the cache memory of their computer, in the DNS server, in their web proxy server, or elsewhere. Caching, like most simple, useful ideas, is ubiquitous.

    Adding caching isn’t too much trouble, but it takes at least a few minutes to modify the code. With all modifications, there’s a chance that you might make a mistake, which has to be factored into the average time. Once you’re done, it may turn out that the caching was a bad idea, because the cache management overhead dominates the running time of the function, or because there aren’t as many cache hits on a typical run as you expected there to be; then you have to take the caching code out, and again you run the risk of making a mistake. Not to overstate the problems, of course, but it will take at least a few minutes in each direction.

    With memoization, adding the caching code no longer takes minutes; it takes seconds. You add one line of code:

    memoize 'myfunction';

    and it is impossible to make a serious mistake and break the function. If the memoization turns out to have been a bad idea, you can turn it off again in one second. Most programmers can appreciate the convenience of this. If you have five minutes to explain to a C programmer what benefits Perl offers over C, memoization is an excellent example to use.

    Of course memoization is facilitated by Perl's lexical scoping, closures, the flexibility of its references, and by its powerful containers (hashes, in this case). In Perl, functions are arguably first class objects.

    It may also be worth discussing why everyone else has "Perl Compatible Regular Expressions", and what Perl's modern regular expressions can do (new constructs from 5.10 through 5.16, embedded code via (?{...}), named captures, (?(DEFINE) .... ) semantics, and so on.

    I also like this paragraph from the preface to Higher Order Perl:

    Around 1993 I started reading books about Lisp, and I realized something important: Perl is much more like Lisp than it is like C. If you pick up a good book about Lisp, there will be a section that describes Lisp's good features. For example, the book Paradigms of Artificial Intelligence Programming, by Peter Norvig, includes a section titled What Makes Lisp Different? that describes seven features of Lisp. Perl shares six of these features; C shares none of them. There are big, important features, features like first-class functions, dynamic access to the symbol table, and automatic storage management. Lisp programmers have been using these features since 1957. They know a lot about how to use these language features in powerful ways. If Perl programmers can find out the things that Lisp programmers already know, they will learn a lot of things that will make their Perl programming jobs easier.

    (Emphasis added.)


    Dave

Re: Get me excited about perl
by temporal (Pilgrim) on Sep 19, 2012 at 18:54 UTC

    I like telling people about how awesome CPAN is =)

    Might be a neat demo to show how quickly, simply, and intuitively you can grab module(s) and accomplish some of these web/batch tasks your audience typically does in their 'native' languages.

    Strange things are afoot at the Circle-K.

      I'll have to chime in with temporal: I think that CPAN is the best initial draw. The capabilities of the language help make it stay great.

      The example I usually use to "hook" people with perl is a stripped down version of my SQL_2_excel script. The stripped down version isn't fancy, but shows how easily you can get data from a database and into a spreadsheet:

      #!/usr/bin/perl # # Create a spreadsheet from an SQL query. # use strict; use warnings; use DBI; use Spreadsheet::WriteExcel; my $DSN = shift; my $usr = shift; my $pwd = shift or die "Missing argument(s)!"; # Attach to database and run query my $DB=DBI->connect($DSN,$usr,$pwd); my $ST=$DB->prepare(<<EOSQL); select MID, DBA, LastName, FirstName from customers where balance_due > 100 EOSQL $ST->execute; # Create a new workbook and worksheet my $xWB = Spreadsheet::WriteExcel->new('MySpreadsheet.xls'); my $xWS = $xWB->add_worksheet("Results"); # Add column headers (use column headers from query results) my $R=0; my $C=0; $xWS->write($R, $C++, $_) for @{$ST->{NAME}}; # Read the query results and write them into the spreadsheet while (my $ar=$ST->fetchrow_arrayref) { ++$R; $C=0; $xWS->write($R, $C++, $_) for @$ar; }

      It doesn't have much in the way of features (no error checking to speak of, no formatting and/or null handling, etc.). But it's easy to see what's going on and shows that you don't need much code for some basic tasks.

      ...roboticus

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

      If you're going to do a live demo, do it against a CPAN mirror running on the same machine so you don't get embarrassed by network snafus! And practice practice practice beforehand. Make sure that the environment you're demoing in is exactly the same as what you practice in!

      If any of them spot that it's a rigged demo (ie a local CPAN mirror) then point out that that's a feature - minicpan is just one of the bounty of treasures on the CPAN.

        Seconding DrHyde on this one - I've actually had one of those 'Oh, well I can just snag this module from this amaaazing and wonderful thing called CPAN and we can demo this! *crickets* ...network...?' moments during a meeting the big-wigs.

        The upshot being that it's not so fun also teaching them about how to tether your phone because the local point of internet access is spotty.

        Some great replies up here, I sometimes forget how shiny Perl really is. Then I am coerced into speaking some other language for a spell... which usually ends in a 'why you should be excited about Perl and be totally using it' speeches, haha!

        Strange things are afoot at the Circle-K.

Re: Get me excited about perl
by CountZero (Bishop) on Sep 19, 2012 at 19:11 UTC
    Tell them Perl has the most friendly user community on the web.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
      Hey, who are you calling friendly?!?
        You!

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        My blog: Imperial Deltronics
        All of us!

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        My blog: Imperial Deltronics
        Me!

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        My blog: Imperial Deltronics
Re: Get me excited about perl
by tobyink (Canon) on Sep 19, 2012 at 19:15 UTC
    use 5.010; use MooseX::DeclareX types => [ -Moose ]; class Worker { has task_list => ( traits => ['Array'], is => read_only, isa => ArrayRef[Str], handles => { add_task => 'push', next_task => 'shift', has_no_tasks => 'is_empty', }, ); build task_list { return []; } method do_work (Int $amount = 1) { for (1 .. $amount) { return if $self->has_no_tasks; say "Doing: ", $self->next_task; } } } role Lazy { before do_work { say "Work?! Do I have to?!" } } class Lazy::Worker extends Worker with Lazy; my $bob = Lazy::Worker->new; $bob->add_task($_) for ( "dig up the road", "pull out the broken pipes", "lay down new pipes", "fill in hole", ); $bob->do_work; $bob->do_work(2); $bob->do_work(3);
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: Get me excited about perl
by grizzley (Chaplain) on Sep 20, 2012 at 08:33 UTC

    When I was preparing similar presentation, I started by stealing Damian Conway's slide from YAPC (sorry Damian!) with one smile emoticon in the middle (just say you are happy they are all here listening to you).

    I focused on what is Perl best at: on logs/text processing. I showed a simple file doing: read input file->read line-by-line->do something on each line->write to output file, something like this:

    open FIN, ... or die ...; open FOUT, ... or die ...; while($line = <FIN>) { $line =~ s/somepattern/somethingelse/g; } close FIN; close FOUT;
    and then started cutting lines introducing $_, -n output redirection and ending with
    perl -ne "s/somepattern/somethingelse/g" infile > outfile

    It was seven slides I guess. After fifth slide audience started begging me not to annihilate whole code... :)

    Then I presented list operations (easy inserting, deleting, merging, dynamic allocation, no bothering about memory, out-of-the range problems, etc.). C++ developers were target of this part of presentation.

    Then one real problem: we had to deal with some Java problem of too long subroutine (it could not be longer than 64kB or something). Subroutine was generated automatically from variables list, 1000 times like:

    setVarAndDoSomething(varname1, value1);
    so perl script had to just split this sub into subs of no more than 64kB. So again operating on text, script was about 20 lines long, basically "read sub from file"->"cut into lines"->"glue together lines to chunks of no more than 64kB"->"replace old sub with set of new ones". To ilustrate it I found pictures: "book" -> "scissors" -> "glue" -> "Indiana Jones replacing golden statue with sack of dirt".

    And at the end I've added info about CPAN, tons of modules, self-testing modules, etc.

    Audience was delighted with power of Perl. So to sum it up: I presented what I like and use most: text processing, power of pure language and core modules. It would be best for you to think how you use Perl and present your way of making your own life easier. And of course remember about good presentation practices: less text, more pictures, present only main ideas on screen, etc.

    Good luck!

Re: Get me excited about perl
by sundialsvc4 (Abbot) on Sep 19, 2012 at 23:53 UTC

    The first thing I would show them is:
    82,750 Uploads; 25,715 Distributions; 112,511 Modules; 10,034 Uploaders.

    And all of these packages self-test themselves on your system and in some cases customize themselves to your system.   They represent a vast library of code that is known to work.   Everything from one-line web servers to literally rocket science.

    And, quite honestly, I just might stop there.   Show a cross-section of what can be done by stringing packages together.   You don’t have to wander too far into what programmers probably already know.   You don’t need to “compare” Perl, much less defend it.   By now, the language speaks for itself.   The core features of the language will be familiar to most, and I almost feel that “the language” is beside the point.

    It’s useful to mention TMTOWTDI™, and also to just show a few examples of why Perl has repeatedly been called the Swiss Army® Knife of computing.   This is, very pragmatically speaking, an extremely useful language ... and in a very “boots on the ground” sort of way.   Like every language it has its quirks; so what.   Let’s talk freight, as in moving it for a living.   This thing very efficiently does what you most need to get done.   Just keep showing synopsis after synopsis of that.

    I still remember this quote:   Actum Ne Agas = Do Not Do A Thing Already Done.   And I think that this notion really summarizes Perl.   Any new code that you write, in order to solve a problem, pales against what you don’t have to write.   To any professional miracle-worker, that’s “Priceless.™”

    This is a language that seasoned practitioners, who of course know a great many languages and more-or-less switch between them throughout the day, tend to keep coming back to.   There is a reason.

    Last but not least, send them here.   Tell them about PerlMonks and specifically encourage them to browse here.   It is one of the best sites on the web in many ways, and not just with regards to Perl.

      Not all of them have tests, not all of them pass their tests, and not all of them work even if they pass their tests. However, you can tell your audience this and turn it to perl's advantage, by talking about the CPAN-testers, CPANdeps and CPxxxAN.

Re: Get me excited about perl
by fluffyvoidwarrior (Monk) on Sep 20, 2012 at 09:18 UTC
    Perl is huge and it can do everything. Even speed is rarely a problem these days. But the real clincher for me is text handling. The world runs on a few hundred characters at almost every level and Perl lets you control this system in almost any way imaginable. Meaning is abstracted from external reality into this system to be manipulated by Perl. On more than one occasion I have solved problems in Perl that teams of cleverer people than me couldn't solve without it.

    Hilarious though it may sound to The Monks, it is not rare for me to be referred to as a computer genius (I kid you not) but the reality is simply that a combination of Perl and real world experience makes one look good to people who don't have either. Perl stands you on the shoulders of giants and gives you intellectual gearing like no system I have encountered in 30 years of programming. It's a problem solving framework, if you can conceive of a thing then with Perl in your toolbox you can usually find a way.

    For example, text handling lets you orchestrate unix systems as problem solving facilities. This gives you almost all the power of the world of modern computing to do with as you will - for the price of a download. Hell, with Perl you can even write systems that write themselves as they run. How cool is that?

    If you think I'm talking too big about a "scripting language", just ponder for a few minutes what Turing could have done with Perl. Having "Many ways to do it" gives you evolutionary options, many pathways are open..



    Maybe you can use some of that?

      Yes, it might be worthwhile to mention the tasks that Larry Wall was originally faced with, all those years ago, when awk wasn’t quite cutting the mustard for him.   Perl has always been exemplary about ripping text strings apart, really doing just about anything with character data, and we all know that we all do a lot of that.   Anybody who’s ever received a wacky file from a client, or who needed to vet it for the mistakes that the client didn’t bother to fix, will instantly identify with any power-tool in that department, especially one with this long of a pedigree.

      I still wince when I read on other forums about what people manage to do with “Bash scripts.”   To me it feels like boasting about being able to cross a raging river on a floating pie-pan (just to show that you can do it?).   Perl gets a lot of use as a simple scripting language, but to that use-case it brings a rich existing-code base and tremendous built-in firepower.

      I think that you get people excited about this language most by showing people things that they know they need to do all the time, and to simply show them what Perl can bring to that requirement.   You don’t have to bury them in detail.   Perl has been doing exactly these things, for people just like them, for a very long time now.   It’s an experienced language ... and people keep choosing it.

Re: Get me excited about perl
by nemesdani (Friar) on Sep 19, 2012 at 20:28 UTC
Re: Get me excited about perl
by GrandFather (Saint) on Sep 20, 2012 at 23:41 UTC

    Much of Perl's power derives from the richness of the language, but the features listed above give huge text and list processing power. Even better, Perl is very portable across platforms with a lot of common file manipulation built in.

    True laziness is hard work
Re: Get me excited about perl
by frozenwithjoy (Priest) on Sep 19, 2012 at 18:27 UTC
    Can you provide some more background about your audience? Do they program in other languages? Do they work in a certain field or do you know their general interests?
      Yes, these are a group of programmers of various languages. We use perl at the University of Buffalo for a lot of web content as well as batch programming, though specifics aren't that important. The main goal is to get people interested in and curious about the language, even if they might never use it for work.

        Interesting audience. I would start out with something like

        'Perl is one of the richest open cross-platform languages out there today... It's been actively supported by a community of developers since 19XX and is routinely called the Open-Source toolkit.'

        Bottom line is I've been doing Perl for so long I've forgotten a lot of the other languages I've used... simply because I have yet to find something Perl can't do for me.
        Once I started, I haven't looked back :)

        I guess the trick would be to grab their attention at the git-go and then show them the Perl OO mechanism, a traditional method (something like top-down design) and then the 'scratch-pad gotta have it now' script. Showing some flexibility and emphasizing the code is as good as the coder.

Re: Get me excited about perl
by BillKSmith (Monsignor) on Sep 19, 2012 at 21:39 UTC

    Most perl programers that I know have started learning perl because they needed one of three modules (CGI, DBI, or Tk). Unless you know that your audience has a different interest, I would concentrate on the application of these three modules.

    Bill
Re: Get me excited about perl
by rpnoble419 (Pilgrim) on Sep 19, 2012 at 22:24 UTC

    I usually end the argument with "IT JUST WORKS." With CPAN, PerlMonks and other sites, its almost impossible not to find the help you need.

Re: Get me excited about perl
by jatill (Beadle) on Oct 29, 2012 at 19:30 UTC
    Presentation went over very well. Thanks for the help.
Re: Get me excited about perl
by bennymack (Pilgrim) on Sep 21, 2012 at 12:53 UTC

    Hey there from Seevast up on North Forest :)

    For batch programming there's GNU/Parallel that is pretty awesome in my opinion. While it's written in Perl, it doesn't require jobs be written in any particular language but it's just a joy to use regardless.

    For web programming there's Plack which has not been mentioned yet but is a pretty exciting and fairly recent development. Show your coworkers how they can make a web framework complete with templating engine and database connection in a few lines of code that can run in pretty much any webserver. Plack commoditized web servers and now it's trivial to write one for every little task.

    If they're more on the PL theory/language nerd end of the spectrum, perhaps show them stuff like Devel::Declare which lets them define mini languages (as long it can be expressed as a subroutine reference) and maybe Keyword::API (never used it myself).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-19 08:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found