in reply to Perl advocacy
- 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:
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:my @elements = {'A'..'Z', 0 .. 9 }; my $i = 0; my @regkey; while($i++ < 15) { push(@regkey,$elements[rand($#elements + 1)]); +} print @regkey, "\n";
And you really don't need that many lines to write that code (since that's one of your major points :)--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 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).my @elements = ('A'..'Z', 0..9); my $regkey = join '', map { $elements[ rand @elements ] } 1..15; - 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:
"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? :)> However, the re engine in Perl is far more sophisticated and > capable of better matchesI 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. :)