Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Perl advocacy

by btrott (Parson)
on Jun 16, 2001 at 00:58 UTC ( [id://88935]=note: print w/replies, xml ) Need Help??


in reply to Perl advocacy

Several comments.
  • You have some examples of Perl code and you say, "it takes less lines to do this in Perl than to do this in Java". But you only give an example of the Perl code! So how am I supposed to believe you that it really takes less lines? (For the record, I *do* happen to believe you, but that's neither here nor there; you're preaching to the converted, here. :)

    And besides, saying that the program takes less lines of code isn't necessarily a reason for choosing Perl over Java. *Why* is it good that a Perl program takes less lines of code? (Maintenance, maybe?) Give them reasons, not just assertions.

  • Make sure that your programs work.

    This program doesn't do what you think it does:

    my @elements = {'A'..'Z', 0 .. 9 }; my $i = 0; my @regkey; while($i++ < 15) { push(@regkey,$elements[rand($#elements + 1)]); +} print @regkey, "\n";
    The biggest mistake is the initialization of @elements. Those should be parens, not curly braces. You have created a list of hash references. Your program prints out:
    HASH(0x80e4a90)HASH(0x80e4a90)HASH(0x80e4a90)HASH(0x80e4a90)HASH(0x80 +e4a90)HASH(0x80e4a90)HASH(0x80e4a90)HASH(0x80e4a90)HASH(0x80e4a90)HAS +H(0x80e4a90)HASH(0x80e4a90)HASH(0x80e4a90)HASH(0x80e4a90)HASH(0x80e4a +90)HASH(0x80e4a90)
    And you really don't need that many lines to write that code (since that's one of your major points :)--
    my @elements = ('A'..'Z', 0..9); my $regkey = join '', map { $elements[ rand @elements ] } 1..15;
    And I'm *sure* that people can golf that down, but that's not really the point. The point is that my code shows some strengths of Perl, rather than looking like ported Java code (synthetic variables, for one thing).

  • Make it clearer *why* they should choose Perl. "Less lines of code" isn't necessarily a reason in itself, and if all of the local universities teach Java instead of Perl, they have a *very*, *very* good reason for choosing Java. You need to give them a counter-argument.

    Anticipate the arguments they're going to give for languages other than Perl. "Java is an industry standard"; "Java is faster"; "Students are learning Java"; etc. Give counter-arguments for these.

  • You say:
    > However, the re engine in Perl is far more sophisticated and > capable of better matches
    "Better matches"? What does that mean? Does that mean, using the same regular expression (eg. "\w+"), I can match "better" strings in Perl than in Java? :)

    I think what you mean to say is: Perl has a more powerful regular expression engine. And then you need to find examples of *how* it is more powerful.

  • One thing about Perl that is very, very good--that Java does not have--is CPAN. I really think you should mention CPAN. :)

    UPDATE: Oops, so you did mention CPAN. However, I think you should make it a stronger point. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://88935]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-04-16 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found