See WhyHatePerl for opposing viewpoints.
- There are different Perl languages for different needs. Perl 5 is the widely used standard Perl and is well supported and understood. Perl 6, which is a different but closely related language to Perl 5, offers a new and different way of approaching programming problems for programmers and language designers.
- Perl 5 releases are predictable. Perl 5 is actively developed by a team of volunteers who make releases on published schedule. Development releases occur every month. Stable releases occur once a year in April.
- Perl 5's version numbering system is easy to understand. All release numbers start with "5.". The second number represents the major version number and the third is the minor release number. A stable release has an even major number while a development release has an odd number.
- Perl 5 has a published support schedule. Each major release of Perl 5 is supported for two years, except for critical security fixes, which are supported for three years.
- It's a MultiParadigmLanguage -- CeeLanguage programmers can write C-style programs, UnixShell hackers can write shell scripts, and even ObjectOrientedProgramming and LispLanguage lovers will find much that is familiar.
- Built-in InternalIteration functions that JavaLanguage makes incredibly complicated: detect, iterate/apply, split, join -- JeffBay grep, map, foreach
- Appropriately simple postfix operators. You can say "do_something() if cond1 == cond2;", but you can't express arbitrarily complicated expressions that way (it would rapidly become unclear).
- Big functionality in small amounts of code
- AssociativeArrays (maps, to you CeePlusPlus folks) are FirstClass objects, as are lists (told you Lispers would like it!) Unfortunately, there's a lot more to it than that, from the perspective of a lisp programmer. See WhyWeLoveLisp.
- Built-in RegularExpression support makes string handling extremely easy. This is especially nice when you want to automate CodeGeneration. -- BillyChambless
- ThereIsNothingPerlCannotDo!
- PerlGolf
- PerlPoetry -- honk() if $you->love('Perl');
- ContextSensitivity
- A Motley Crew of Developers -- http://www.pm.org/ -- JohnBeppu
- The PerlCommunity?. It's a way of life, a whole culture based upon just a few facts and a great degree of freedom. Perl6 is being designed by the PerlCommunity?, although we asked (well, some did) LarryWall to keep control of things... after all, he's the father of the beast, and we love it to be Perl... -- DavidDeLis
- LexicalClosures. -- SethGordon
- What takes 100 lines in other languages might take 10 in Perl
- Perl lets you think like you instead of trying to smash your brain into the shape a computer wants it to be.
- PerlTestingTools
- Easy to DoTheSimplestThingThatCouldPossiblyWork
- TheCpan: the best code repository anywhere ... -- DaveTauzell
- It doesn't get in the way or try to tell you what's "good" for you.
- One of the most interesting descriptions of Perl I've ever read is that it's a language where you can easily "make braindumps executable" (although that statement was put into perspective when I learnt RubyLanguage) (moved from PerlProsAndCons)
- You can do what you want to do and you can do it right away!! Perl should be taught in HighSchool. -- PerlPathi?
- Perl is just a bunch of useful unix libraries with a grammar thown over them and made portable by people fascinated with synergy. CPAN, on the other hand, is a remarkable social demonstration enabled by that synergy. -- WardCunningham
- What takes 100 lines in other languages might take 10 in Perl (could we have a simple example?) -- DonaldNoyes
Implement a basic version of uniq. I.e., write a program that goes through its input files and prints out the unique lines it sees. Try to make it perform reasonably well. In Perl that is short enough that you can write it on the
CommandLine:
perl -ne 'print if 1 == ++$s{$_}' input files here
In most other languages this program would be substantially longer.
How would it look if instead of ' input file here, you would make it a directory and all its subdirectories? Would this be possible? -- DonaldNoyes
By and large, the savings with Perl are due to comparing a ScriptingLanguage with non-scripting languages like JavaLanguage and CeeLanguage. Perl does not have such a huge advantage against other scripting languages. (Particularly RubyLanguage.) -- BenTilly
perhaps UniqInManyProgrammingLanguages? to test both the original claim and this counter-claim?
I know this sort of thing gives perl a bad name, but we can golf that script down to
perl -pe '$s{$_}++&&undef$_'
:-). My personal preference, however, would be
perl -ne 'print unless $s{$_}++'
--
DaveWhipp
Incidentally, the uniq replacements above don't actually produce the same answers as the real uniq(1) command (the real uniq(1) requires the input to be sorted)
try with the input file
1
2
1
The reader is invited to draw his own conclusions on what if anything this says about the perl mindset ;-) --
DanBarlow
That brevity is more important than correctness? ;-)
That it's close to the ExtremeProgramming mindset? In that the code solved the stated problem, i.e., 'Implement a basic version of uniq.', instead of some other problem.
But it's not in Basic, it's in Perl! <ahem> But seriously, folks, if it doesn't meet the requirements, what good is it? Brevity is all well and fine, but correctness is a lot more important to my clients, methinks. Particularly when you look at the mess Perl makes of the argument set - it's composed entirely of Perl-unique descriptors. Wonderful to a Perl guy; a complete and impenetrable mystery to anybody else.
Just as in the futile arguing over the loverly characteristics of ExtensibleMarkupLanguage we are once more focusing on brevity and ignoring clarity. Why are we still doing this? "Doctor, it hurts when I do this." "Well, don't do that."
For what it's worth, it's easy to match the functionality of uniq more closely:
perl -ne 'print unless $s eq $_; $s = $_'
That performs much more reasonably (memory-wise) than the first example. The first example will chew up memory on large files. You'd probably use the DB_File module or somesuch if you wanted the exact functionality of the first example.
Let's try that with slightly different words. "Perl has a
DataStructure that it calls a list, which exposes an approximate subset of the functionality in a real
LinkedList". As a
LispLanguage programmer I really don't find this any more exciting than the news that it supports subroutines would be to a
CeeLanguage programmer. (
AwkLanguage programmers, however, are thrilled to have both.)
How about Perl shares six of the seven features of Lisp listed in the "What makes Lisp Different?" section of "Paradigms of Artificial Intelligence Programming" (http://hop.perl.plover.com/preface.html).
The thing to keep in mind about Lisp, however, isn't just that lists are FirstClass objects--it goes much deeper than that. In Lisp, programs are written as lists, and programs are literally just AST trees. This, in turn, makes it very easy to alter Lisp to make it fit the program domain. Languages that have syntax have trouble with this. Perl has incredibly dense and complicated syntax, so it's at the opposite end of the spectrum compared to Lisp. Because of this, it is highly unlikely that Perl will cross the threshold to become a Lisp. --Alpheus
I just saw http://cpan.uwinnipeg.ca/dist/Filter-Simple which is really impressive. The lispiest thing I've seen in perl.
Perl isn't a language designed to be placed in a museum and looked upon as a thing of beauty. It isn't designed to follow a particular decades-old aesthetic of neatness, one that's progressed through languages like PascalLanguage and and ModulaTwo and EiffelLanguage. A classic tenet of such neatness is that the core language should be minimal, and everything you need is in a library. As a purist, that agrees with me. But at the same time, a language is used to get things done. Having flat, immediate access to a large number of useful features and coding styles is what makes Perl useful. For example, there's no need to bring in a RegularExpression library, then have to precompile each expression, referencing it by a handle. There are also little, catchy constructs that cover common situations. "total++" in CeeLanguage isn't cryptic; it's clean and clear and it's shorter than "total = total + 1". You get used to the conciseness of idioms like:
while (<>) {
print if /START/ .. /STOP/;
}
to print all the lines from START to STOP in a file, inclusive.
There's also a good use implicit information in Perl. You don't need to call a function to get the length of a list. You use a list in a scalar context. The information is already there, and using it leads to concise and free-flowing programs:
$test = "a2b4c6d8";
@list = ($test =~ /(.)/g); # for a less general case use @list = split //, $test;
%hash = @list;
This code builds a hash of (a,2),(b,4),(c,6),(d,8) from the $test string.
Perl isn't perfect. It falls down hard when it comes to nested DataStructures, even passing such structures to subroutines. But for a good chunk of everyday work, Perl is perfect.
-- JamesHague
- Using nested DataStructures, and passing them to subroutines by reference is a trivial task in Perl. What makes you say that Perl "falls down hard" when it comes to using them? -- JustCurious?
- Compare nested data structures in PerlLanguage to PythonLanguage, for example. In Python, all data structures can be nested right out of the box. In Perl, there is separate syntax for flat structures and references to structures. I agree that it's not as horrible as it used to, however.
It runs on just about any platform including Windows, Macs, VMS, most Unices (I am hesitant to say all but it has been on every Unix system I have seen) and MainFrames. Can you say 'Portable'?
I think that
- It doesn't get in the way or try to tell you what's "good" for you.
- Perl lets you think like you instead of trying to smash your brain into the shape a computer wants it to be
- You can do what you want to do and you can do it right away!! Perl should be taught in HighSchool. -- PerlPathi?
should be refactored in just one sentence.
We could take a dig at the ObjectOrientedProgramming crowd and say that PerlLanguage is an accurate model of how people think :)
Metaprogramming - perl has a lot of little, somewhat orthogonal tools that can play different parts in this.
- UNIVERSAL and AUTOLOAD
- Variable (including subroutine) attributes
- Symbol table access at runtime
- The different pieces of perl ObjectOrientation (packages, bless, @ISA)
- FunctionalProgramming tools
- eval
Try running through the
CatalystFramework tutorial, which uses DBIx::Class::Schema. Several of these are at work there, either visibly or behind the scenes.
CategoryPerl