Slashdot Mirror


Perl 6 Now by Scott Walters

Joseph Brenner writes "Every now and then, a beginning programmer asks if there's any point in learning to program in Perl 5, when Perl 6 is going to change everything soon. There are a number of answers to that: one is to point out that Perl 6 is still years away, another is to point out that it is promised that Perl 5 code will run under Perl 6 without modification (a module that begins with the traditional "package" statement is Perl 5 code; if it begins with the new "class," then it's Perl 6)." Read on for the rest of Brenner's review of Scott Walters' Programming in Perl 6 style using Perl 5, a book which answers that question a whole different way. Perl 6 Now author Scott Walters pages 379 publisher Apress rating 7 reviewer Joseph Brenner ISBN 1590593952 summary Programming in Perl 6 style using Perl 5

Scott Walters here pursues what might be thought of as the third answer: you can learn Perl 6 now and immediately begin writing programs in a "Perl6ish" sort of way, using appropriate CPAN modules that have been used to implement approximations of Perl 6 behavior: Perl6::Variables, Perl6::Export, Perl6::Contexts, autobox, Perl6::Classes, Switch, and so on.

There are many caveats about using these tricks in production code, however, and Scott Walters doesn't shy away from warning you about them (e.g. p.43 "Source filters are dangerous" where he discusses their increased start-up overhead and potential bugginess -- though he doesn't mention my own peeve which is that they're very confusing when you try and use the Perl debugger).

So possibly the book is not really quite so well suited to an actual beginner-- who probably should not be told about "use Switch 'Perl6'", but the device of spending the early stages of the book directed toward a beginning audience makes it a very useful review for people like myself who have been reading the Apocalypses, but don't remember every detail.

And on the other hand, the book includes some prominent early warnings about common gotchas that beginning programmers seem to be prone to -- e.g. using dynamically defined variables instead of just using hashes.

The standards for writing English in the Perl world are pretty high -- the core members of the Perl community have always cared a lot about clear writing, and it's arguably the world's best documented language (critics will no doubt add that it needs to be). Unfortunately, I can't say that Perl 6 Now quite lives up to this standard. This is a book that was written in a hurry, and it shows: hasty sentences and minor organizational problems abound (e.g. one or two items seem to be discussed in the wrong place; there are an awful lot of explicit forward references, and yet there's at least one place where something was used in an example before being discussed a few dozen pages later). But then in Scott Walters defense, this is certainly a book that needed to be written in a hurry, because its subject matter is such a moving target.

And where the book really shines is in its code examples: short, clear and to the point; the author repeatedly shows how something can be done in Perl 5 code and how it's expected to work in Perl 6. These examples are always clearly labeled "Perl 5" or "Perl 6" in the comments, so that the two can't be confused.

The subjects of some of the examples are pretty cool: e.g. he talks about using PDL ("Perl Data Language") to crunch audio data in MOD format, which I was completely unfamiliar with. A *.mod file essentially contains the "sheet music" for multiple parts (really, MIDI) plus sound samples that specify how notes will sound for each voice. This is discussed in Chapter 7, which is also the free sample chapter. I also liked random walking Arizona's highways as an example of Graph navigation (Chapter 8, p 159), and I appreciate the fact that he downplays inheritance in favor of delegation in his discussion of objects (Chapter 14, p. 262).

All in all, this book is a fun read for the Perl fanatic.

(Note: the title Perl 6 Now bears a strong resemblance to an emacs package I've been working on called perlnow.el, but there is no relation.)

You can purchase Programming in Perl 6 style using Perl 5 from bn.com; it's also available in eBook format (password protected PDF, using your email as password) for $15. Source code and and a sample chapter are available online: Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

51 of 366 comments (clear)

  1. Re:Perl 9 is already out... by Gunny101 · · Score: 2, Interesting

    It's interesting that books on Perl 6 are released when the Perl 6 is still in development. I understand modules for Perl 5 exist that can utlize some Perl 6 features, but still... Someone should release a book on Windows Vista now that a beta is out.

  2. PHP5! by Douglas+Simmons · · Score: 5, Funny

    I hate to be Jonny Raincloud, but pretty soon PHP will be able to do whatever perl does, if it's not there already. And anything that it can't do that perl can will be obsolete. So no, don't waste your time learning perl 6. Do the right thing and brush up on your PHP5. I got my site to print in any font I want the time AND date, powered by php, baby!

    1. Re:PHP5! by Nuclear+Elephant · · Score: 4, Funny

      Does PHP have the equivalent of CPAN?

      Who would want a language that had its own mediocre congressional television station?

    2. Re:PHP5! by utopianfiat · · Score: 2, Interesting

      s/(1|2|3|4|5|6|7|8|9|0|one|two|three|four|five|six |seven|eight|nine|ten|eleven|twelve|thirteen|fourt een|fifteen|sixteen|seventeen|eighteen|nineteen|tw enty|thirty|forty|fifty|sixty|seventy|eighty|ninet y|hundred|thousand|million|billion|trillion)/<b>\1 </b>/g

      Look, I'm violating patents!

      --
      +5, Truth
    3. Re:PHP5! by Spy+der+Mann · · Score: 2, Informative

      Does PHP have the equivalent of CPAN?

      Yes, it's called PEAR: The PHP Extension and Application Repository.

    4. Re:PHP5! by jallen02 · · Score: 3, Insightful

      Pear only has a handful of modules compared to CPAN, in all fairness.

      Jeremy

    5. Re:PHP5! by Momoru · · Score: 2, Funny

      BTW, It is customary to use the abbreviation NSFW when you post a link like this.

      I believe as the ass ambassador, he is entitled to diplomatic immunity in this case.

      At least I hope so since he is publishing so many copyrighted images illegally....

  3. Clear writing by Sweetshark · · Score: 4, Funny

    The standards for writing English in the Perl world are pretty high -- the core members of the Perl community have always cared a lot about clear writing
    Yeah, right. Why should one obfuscate English, Perl offers much more possibilities to do so.

  4. Re:I hate Perl. by mopslik · · Score: 2, Funny

    What is the output of the following?

    "Be Sure To Drink Your Ovaltine." What the...?

  5. Re:Perl 9 is already out... by hahafaha · · Score: 2, Funny

    Would you care to provide any reasons for switching to Python?

    Holy wars such as Perl vs Python are typical but altogether unneccecary. Both Perl and Python are maturing and are now sophisticated languages. Furthermore, they are suited for different things. For example, if I were writing a program that needed advanced string parsing, I would use Perl. If I was writing a graphical game, I would use Python. If I was writing a CGI script, I would use Perl. If I was writing a program that described various objects in space, I would use Python.

    There is no reason to get so defensive about these things with the exceptions of Windows vs Linux (Linux) and Emacs vs Vi (Emacs).

  6. CPAN by kevin_conaway · · Score: 4, Insightful

    I believe that CPAN is one of the major (if not the only) things keeping Perl alive and well.

    It is a great language, and has been used successfully by many huge companies (Amazon for one), but I think if those companies had to redo it again today, I don't think they would choose Perl again. I think that purely as a language, it has been surpassed.

    Having a large, mature 3rd party library is what is hampering the adoption of some of the up and coming languages.

    1. Re:CPAN by radtea · · Score: 5, Insightful

      I believe that CPAN is one of the major (if not the only) things keeping Perl alive and well.

      My own experience suggests this is absolutely true. I learned a bit of Perl in 2000, then had a look at Python, and realized that 90% of what I wanted to do, no matter what I wanted to do, was already implemented in Perl modules. Python, in contrast, had a a much, much smaller collection of stuff available. Despite certain nice features in Python, the abundance of pre-existing native functionality in Perl won the day for me.

      One could argue that Perl functionality can always be called by other languages, but I have extensive experience in mixed-language programming (C/FORTRAN, C++/Java and Perl/C++) and don't really want to deal with the debugging nightmare that it often entails. So given that I could do everything I wanted to in Perl and still live by Booch's Rule 122 ("Never write code unless you absolutely positively must"), Perl was the clear choice.

      The only likely replacement for Perl is Perl, as Perl6 will be able to draw on the huge community of Perl developers who have a vested interest in keeping the language alive and flourishing, and it is very likely that debugging from Perl6 into Perl5 will be relatively seamless.

      --
      Blasphemy is a human right. Blasphemophobia kills.
  7. Re:It's a php/perl post! by Black+Perl · · Score: 3, Informative

    Where are the Ruby on Rails people? I expected 100 of them to speak up before the traditional "FRIST PSOT!!!"

    Well, for one, perl now has a nice framework similar to Rails called Catalyst (http://catalyst.perl.org/). It's a lot closer to Rails than a lot of other languages' attempts to clone Rails. And yet the Catalyst dev team have specifically chosen to diverge from Rails in certain areas, trading a bit of simplicity for complete flexibility, avoiding some limitations you could run into in Rails.

    --
    bp
  8. PHP5? by matt+me · · Score: 2

    You're joking, it's not PHP that Perl has to compete with, it's Python! PHP will always be slower than mod_perl 2 on Apache2 (bbc.co.uk runs on this and it is a monster), but Perl's primary use is not for server scripting (mod_perl) but as a power tool. Whenever you need to do something with your system beyond the power of shell scripting, use Perl;

  9. Moving from Perl (slightly OT) by Seumas · · Score: 3, Interesting

    I was going to bring this up in the thread about beginning programming the other day, but I came too late to the party. Hopefully someone can offer me some advice.

    First, I'm not really a programmer. Not professionally, at least. I've been writing Perl for about four or five years, though. I'm not well-versed in OO and I'd like to be. I've just found it such a stumbling block in Perl and that's probably because I'm doing in Perl in the first place. It's the first language I picked up since I played around with BASIC and Pascal as a little kid.

    I run a large auction site. Maybe 40,000 members. I wrote the entire engine (auction, forums - everything) in Perl. But it's getting complex and difficult to maintain as it is. And the performance is not holding up. I could move to mod_perl, but rather than re-writing everything (and possibly doing so in OO), I thought I'd just write it in another language.

    I don't want PHP. So that leaves me mostly with Python and Ruby. I've done a lot of reading, but am not sure which would be more appropriate. I think Python might stick me back in the old "easy to do things wrong and blow your foot off" world of Perl. Ruby on the other hand would probably help me gain a better understanding and real-world use of OO.

    Performance is an issue. So are available packages. My backend is postgresql and I need whatever language I use to have an extremely capable and flexible and mature postgresql DBI.

    At the moment, I have to say I'm leaning toward Ruby. But it does seem that Python might have more mature packages available to it and be a bit more widely used. I'm just skittish because everything I've heard has given me the impression that it's very Perl-ish and if I'm going to be in that world, I might as well just stick with Perl in the first place.

    Thoughts?

    1. Re:Moving from Perl (slightly OT) by Marc2k · · Score: 4, Insightful

      No. Here's your main problem:
      First, I'm not really a programmer.
      I wrote the entire engine.
      But it's getting complex and difficult to maintain as it is.
      And the performance is not holding up.

      So you're admittedly not a very experienced programmer, and you're expecting to have the web logic engine that you built, presumably from scratch, be scalable and modular, without ever refactoring it? In programming, we call the kind of query you just gave a 'silver bullet' problem, and unfortunately, there is none in this case. No one language, or framework, for that matter, is going to fix problems inherent in poor design. That's not to necessarily denigrate your programming skills, but don't expect that rewriting an app that was developed from scratch and is exhibiting growing pains to see great speed and modularity gains by porting it to another language. I've got a good hunch that if you started all over again, still using Perl, and chose your toolset wisely, your app would be more stable, scalable, functional, and modular.
      I've worked with a lot of web languages/frameworks, and yes, Ruby would similarly solve the problem, but please don't ever say "real-world use of OO" with regard to Ruby. Rails is what, a year old? Basecamp and 43 Things are the largest sites actually running Rails (the latter being as esoteric as you can get, and pretty low-traffic, at that), and you're not going to see a major player using Ruby at this poing. If I take your meaning of "real-world" correctly, CORBA is more like what you're talking about, though I don't think you necessarily want to mess with that sort of thing right now.

      --
      --- What
    2. Re:Moving from Perl (slightly OT) by qlippoth · · Score: 3, Insightful

      Performance is an issue. So are available packages. My backend is postgresql and I need whatever language I use to have an extremely capable and flexible and mature postgresql DBI.

      From the standpoint of integrating a website/database, the database will always be your substantial performance bottleneck, unless your code is utter garbage. PHP, Python, or Ruby are all adequate for this task.

      The biggest thing you can do for performance is design a Normalized database, and to make sure there is proper indexing for all the queries you run. If you put adequate research and effort into these areas, you'll see better performance gains than putting any effort into rewriting code.

      --
      Mmmm, -funroll-loops
  10. Show some "unreadable" Perl code or shut up by defile · · Score: 5, Insightful

    Everyone attacks Perl code for being unreadable but I don't think I've ever come across real world Perl code that I couldn't manage to deal with (eventually). I've seen some bad code and written some bad code and Perl doesn't have exclusivity in either of those areas. ;)

    Does someone have a good example of unreadable, real world Perl code? And I don't mean obfuscated Perl contest entries.

    When it comes down to it, other people's code is just freakin' unreadable no matter what they write it in. In fact, my own code looks unreadable and unmanagable if I haven't seen it in awhile. Just the nature of the industry.

    Maybe Perl is just a high profile target since the internet is full of small (and useful) pieces of Perl code?

  11. You mean slashdot isn't based in Poland? by rebug · · Score: 2, Funny

    Yow!

    --

    there's more than one way to do me.
  12. Re:Pointless Perl6 by A+beautiful+mind · · Score: 3, Informative

    Please do not moderate parent up, because it's just a guess at most.

    Perl6 is actually built from user feedback, for the first time.

    From wikipedia: Larry Wall, the creator of Perl, has called Perl 6 "the community's rewrite of Perl", because he has based the changes largely on 361 "requests for comments" submitted by the Perl community in 2000. He is outlining these changes in a series of long essays, called Apocalypses, which are numbered to correspond to chapters in Programming Perl ("The Camel Book"). The current, unfinalized, specification of Perl 6 is encapsulated in design documents called Synopses, which are numbered to correspond to Apocalyses.

    Parent is NOT insightful.

    --
    It takes a man to suffer ignorance and smile
    Be yourself no matter what they say
  13. Re:Attracting new users, competing with Python? by Coryoth · · Score: 3, Informative

    Perl6 has the advantage of starting from the beginning, taking all that was learned from the evolutionary development that lead to Perl5, as well as the lessons learned from other languages like Python and Ruby. Honestly, read through the design commentary for Perl6 by Larry Wall. There are a lot of good ideas there, and Perl6 promises to be a much cleaner, more consistent and more elegnt language than Perl5 - that is, it has learned what was good in Perl5 and thrown away the (vast amounts) of cruft. Looking at what they're proposing, if it actually works as promised then I do think it will compete well with Python - and I'm a Python person myself*. Honestly, read a little of what Perl6 has to offer before you dismiss it out of hand. It looks like it will be a very nice language indeed.

    Jedidiah.

    * One of the things I like about Python is that they're willing to deprecate and then *remove* features to help combat cruft.

  14. Re:Are people still using PERL? by Lost+Found · · Score: 2, Informative

    Actually, mod_perl performance beats the pants off everything but raw C modules when doing Apache web applications.

  15. Re:Are people still using PERL? by hahafaha · · Score: 3, Informative
    This is very far from the truth. Perl is still used heavily for many things ranging from games to CGI.
    I thought it was a passe fad like Java.

    The same goes for Java.
    Seriously, doesn't it remain too slow in execution spped ... and the quick knock off jobs you can do with it are better done in bash and awk?

    Bash and Awk are not powerful enough to do some of the jobs Perl can do. And Perl is only slow with some things, and in comparison to really serious languages like C/C++.
  16. Perl6 is closer than you think by jjn1056 · · Score: 4, Informative

    check out "http://pugscode.org/"

    for a working perl6 compiler. Yeah, it is not yet feature complete, but progress is very rapid.

    Perl6 is really amazing. It removes most of the worst parts of perl5 and make things even easier on the programmer. If you do an research at all you can find that.

    Some people are even starting to port important CPAN modules to perl6 and discovering how much a pleasure it is to use.

    see http://www.perl.com/pub/a/2005/07/28/test_builder_ p6.html

    as an example of that.

    btw, check out the example code. for all of you who think perl5 looks like static on a tv screen, you will be pleasantly surprised I think.

    peace

    --
    Peace, or Not?
  17. For the fanatic by DysenteryInTheRanks · · Score: 2, Insightful
    The review concludes by saying the book is "a fun read for the Perl fanatic." So post that review on Perl.com and tell us here on Slashdot why any non-fanatical programmer would want to use a half-baked imitation of an unwritten language.

    I love and use Perl. But the grammar is already rich and varied. Throwing incorrect Perl6 code into the mix is going to make Perl5 code even harder to read. I sure hope not too much of this stuff makes it onto CPAN (although I know some of it already has).

  18. I used to use Perl, now I'm only doing RoR by duffbeer703 · · Score: 5, Funny

    Ruby on Rails blows away Perl. I used to code in Perl, but I was working on re-implementing Windows XP as a Firefox extension, and I just wasn't getting the productivity that I wanted out of Perl.

    So I switched to Ruby on Rails this morning, and I'm so productive, that its sick. Within 5 hours, I have a Firefox extension running on my AIX workstation that can run most Win32 software... Photoshop, Outlook and Half Life 2 work ok, although I only get 40fps with HL2. (I'm working on that)

    After dinner I'm going to reproduce every module in the CPAN library, which I estimate will take approximately 2.25 hours. I can't wait!

    --
    Conformity is the jailer of freedom and enemy of growth. -JFK
  19. Contrarian View by Anonymous Coward · · Score: 2, Insightful
    PERL5 is already sufficient. Going beyond sufficiency will destroy the language.

    PERL5 is (relatively) compact. It does what it needs to do. I can quickly write fast and compact programs to do dirty tasks like extracting data from a log file. Moreover, I can easily decipher another person's PERL program.

    Attempts to bloat PERL to include every conceivable widget is little more than an ill-advised attempt to morph PERL into a full-blown development language (e.g. C#) for creating million-line programs. Does anyone remember PL/1? It was supposed to be the be-all/end-all language and incorporated so many bells and whistles that few programmers actually learned how the entire language worked.

    Remember the wisdom of the ancients: bearded, graying, almost senile UNIX programmers wearing code-bottle-thick eyeglasses. KISS means "Keep It Simple Stupid".

  20. Re:Is there a point to Perl any more? by CDarklock · · Score: 4, Interesting

    I stopped using Perl over ten years ago, when I had a disagreement with Tom Christiansen and he seriously threatened to blacklist me from the Perl community if I didn't agree with him. I told him to go ahead, because I would simply never write Perl again. He laughed and told me to let him know how that went.

    Well, it went just fine. I haven't written a single line of Perl since that day, and I haven't missed it one bit.

    These days, with so many options available, I think Perl appeals to a certain kind of developer in much the same way Java does. You don't really NEED it, in the sense that many other things can do the same job... but it's a point of style. Java and Perl now serve primarily as focal points for very small and specific communities that otherwise wouldn't really exist in a coherent fashion, much like APL or Objective-C. Ruby is similar, and I don't really see it going mainstream. These sorts of niche technologies still do the job, and selecting one of them instead of a more "mainstream" language like PHP or C++ identifies you as a particular kind of person.

    --
    Microsoft cheerleader, blue flag waving, you got a problem with that?
  21. Re:Perl: Lead Painted Asbestos Toys for Tots by Anonymous Coward · · Score: 3, Funny
    It's simply irresponsible and foolish to use Perl.

    Every time you post a message to this website, you're using Perl. You'd better stop before you foolish irresponsible behavior catches up with you.

  22. Re:Attracting new users, competing with Python? by belg4mit · · Score: 2, Informative

    It's a false perception. 5.6 was leaps and bounds above 5.0.5, and 5.8 is a quite a stride past 5.6.
    Not everyone buys into 1, 2, 3, 95, 98, 2000 type
    numbering schemes :-P There was even a proposal that
    perl 6 should be the last major number and the versioning should approach 2pi

    --
    Were that I say, pancakes?
  23. about package statement by guacamole · · Score: 2, Interesting

    So, what happens if I use perl6 to run a script that has neither "package" nor "class" statements in it. How is it going to decide which language is that?

    1. Re:about package statement by chromatic · · Score: 2, Informative

      Then run it with Ponie or your existing Perl 5 compiler, or add package main; at the start if you change your hash-bang line to /usr/bin/perl6 instead of /usr/bin/perl.

      The point of the check is to re-use modules, not standalone scripts, so that you can migrate your code to Perl 6 gradually.

  24. Why is Perl so hated? by Lost+Found · · Score: 4, Insightful

    I've been asking myself a lot lately why so many people seem to hate Perl. After spending the last few years going from comfortably familiar to extremely familiar with the syntax and features, I think I have the answer.

    When you really get down into the guts of perl, you get to do all kinds of crazy nifty things with XS, AUTOLOAD, regular expressions, etc. Perl's syntax is such that once you're intimately familiar with it, you can be either very expressive or very concise.

    A lot of code ends up going the concise route because when you know what you're doing, it's easier to write (less keystrokes). Then perl newbies / passer-byers take a look at it, don't understand it, and freak out and say that perl is crap.

    Then perhaps they're threatened because there's a huge community of smart perl programmers that manage to upstage them constantly.

    To zoom out on the issue a bit, I'm really sick and tired of this current movement in computer science where so many think that programming should be made into some kind of simple task that anyone can do. Hence you end up with languages like Java that hold your hand really really tight and refuse to let go. Is Grandma writing software really a good thing? Or should we save it for the people who at least have a passing familiarity with computers & networks; hell, someone who might even know a little bit about the basic mechanisms in a typical UNIX kernel?

    (I refuse to drive a car built out of legos... I don't care that the technology enabled your three year old to do it... it's a high speed highway, damnit, and my life is on the line!)

    Make no mistake - there's still an undergound of brilliant developers that understand their systems inside out and produce amazing, high performance code. Many of them are in the open source community. And we refuse to let go of our power tools. You may use whatever language you like, but expect a well-deserved ass kicking if you get in our face and try to tell us you know better.

    1. Re:Why is Perl so hated? by learn+fast · · Score: 2

      A lot of code ends up going the concise route because when you know what you're doing, it's easier to write (less keystrokes). Then perl newbies / passer-byers take a look at it, don't understand it, and freak out and say that perl is crap.

      Fewer keystrokes should not be a design goal of a language. Do you remember the first time you wrote a C program, and you named your first variable 'a', your second 'b', until you got up to say, 'l' or so, and then you realized that you saved a lot of keystrokes but it was impossible to tell what your program was doing. Then after that you got smart and started to give your variables descriptive names. The extra time you spent typing was less than the time you saved when trying to understand what the program was doing upon a later reading.

      Somehow perl never learned this lesson.

    2. Re:Why is Perl so hated? by Sweetshark · · Score: 3, Insightful

      Then perl newbies / passer-byers take a look at it, don't understand it, and freak out and say that perl is crap.
      And in a way they are right: Perl is crap for RAD by now compared to other languages.
      Then perhaps they're threatened because there's a huge community of smart perl programmers that manage to upstage them constantly.
      Yeah, the zealots and their praises are probably one the main reason for the hate against perl. Its just not that good as the zealots claim. Thus people are disappointed.
      To zoom out on the issue a bit, I'm really sick and tired of this current movement in computer science where so many think that programming should be made into some kind of simple task that anyone can do.
      That sounds so elitist it hurts. But yes, programming should be as easy as possible, but not easier.
      Hence you end up with languages like Java that hold your hand really really tight and refuse to let go. Is Grandma writing software really a good thing?
      Grandma uses VisualBasic or PHP, but not Java. Oh, and its a lot better when Grandma writes software in Java than in PHP or Perl.
      Or should we save it for the people who at least have a passing familiarity with computers & networks; hell, someone who might even know a little bit about the basic mechanisms in a typical UNIX kernel?
      No. Your Perlcode might even run on a Non-UNIX System - this is one of the reasons to use Perl, Python, Ruby or Java.
      ... it's a high speed highway, damnit, and my life is on the line!
      So you prefer to use a very powerful old car without any safety measures, because "you can handle it". Yeah, right.
      Make no mistake - there's still an undergound of brilliant developers that understand their systems inside out and produce amazing, high performance code. Many of them are in the open source community. And we refuse to let go of our power tools. You may use whatever language you like, but expect a well-deserved ass kicking if you get in our face and try to tell us you know better.
      Uhhh, Im scared. You really remind me of this guy: http://www.pbm.com/~lindahl/real.programmers.html

      Those who live by the sword get shot by those who don't.

    3. Re:Why is Perl so hated? by Anonymous+Crowhead · · Score: 2, Insightful

      If you code like you respond to comments, I bet your code looks like crap in any language.

    4. Re:Why is Perl so hated? by chromatic · · Score: 2, Interesting
      Fewer keystrokes should not be a design goal of a language.

      Your objection is silly and I think it's because you focused on variable names at the expense of what Perl really tries to optimize, Huffman-wisee. The driving question of Perl (and especially Perl 6) design here is "Why should common operations require a lot of syntax?" In English, why should words such as "he", "she", "I", "you", and "it" be short instead of long? Why is say a better keyword to print a string with a newline attached than print_with_newline?

      One answer is to let meaningful identifiers stand out more.

      Granted, there are tradeoffs. I've seen the Sieve of Eratosthenes in APL and it's fairly dense -- but somehow good people get by with learning a little bit of notation. (The waterbed theory of complexity applies here too).

    5. Re:Why is Perl so hated? by HorsePunchKid · · Score: 2, Insightful
      I hated Perl because it sat in the festering wasteland between shell scripting and full-blown compiled languages. Why would you want the complexity of C++ with the functionality of Bash? I learned the basic syntax about seven or eight years ago and decided there was no place for Perl in my toolbox. Not for lack of room; it just wasn't worth knowing.

      Of course it turned out that I was competely wrong. I was sitting down to dinner with a friend, and he was going on and on about all the different ways the various brackets and braces and parentheses are interpreted in different contexts in Perl. It was actually very interesting in a morbid sort of way; like how your eyes fixate on the wreck on the other side of the highway.

      Then my friend pointed out the simple joy of perl -ne '...'. This little construct kindled something in the back of my mind, and I knew when I got back to my computer that I'd have myriad uses for it. All of those things that I used to do with huge series of commandline pipes and the occasional chunk of Java could be compressed down into one line. One totally illegible and unreusable but completely accurate line.

      find . -name \*.m3u | perl -n -e 'chomp; ($dir=$_)=~s/[^\/]*$//; $play=$_; $bad=0; open(PLAY, "> $_"); while(<PLAY>) { chomp; s/\r//; if(/^[0-9].\. / || /^[0-9]. - / || !/mp3$/) { $bad=1; warn "Ignoring $play\n"; last; } rename($dir.$_, $dir.($. $.. $_\n"; } close(PLAY); if(!$bad) { opendir(DIR, $dir); @files=grep { /^[0-9].\. / } readdir(DIR); closedir(DIR); rename($play, $play.".old"); open(NUPL, "> $play"); foreach $file (@files) { print NUPL "$file\n"; } close(NUPL); }'
      Any idea what that does? No? Well, it doesn't really matter, since no one will ever use this code ever again, but it did its job, and it did it well!* Now that I've seen the light, there are all sorts of little tasks that I find Perl ideally suited to.

      I no longer hate Perl.

      * This code went through all of my mp3 file hierarchy, reformatted the filenames to start with the track number, based on the order they appeared in the .m3u playlist, then generated a new playlist with the new filenames.

      --
      Steven N. Severinghaus
    6. Re:Why is Perl so hated? by chromatic · · Score: 2, Informative
      count($arr) is better than $#arr because it's bleeding obvious what count($arr) does.

      Not to me. count($arr) should always return 1, unless you meant count( @arr ) and want to break the consistency of list flattening everywhere else in the language. Of course, in Perl 6 you can say @arr.elements to get the number of elements in the array (though "elements" is a long method name, so there may be an alternate at some point if there's a good, clear, shorter synonym) or evaluate the array in numification context with +@arr.

      And if you didn't know what $#arr does, there's no way to index that sort of thing in manual.

      Sure it is! See perlvar, one of the oldest documentation pages. (If you never even knew of that page, it's well worth your time to browse the perltoc manpage.)

    7. Re:Why is Perl so hated? by nihilogos · · Score: 3, Insightful

      All this is dealt with in a consistent way, the section on references in "Programming Perl" took me a few reads but it eventually made sense.

      I like the part where Larry is describing the thing a reference refers to, which is termed a "thingy, in honour of the thingy that hangs down the back of your throat". Then there's a footnote that says "You could also call it a 'referent', if you prefer a joyless existence."

      Python zealots always strike me as the type of people who'd call it a 'referent'.

      --
      :wq
    8. Re:Why is Perl so hated? by CoughDropAddict · · Score: 2, Insightful

      Why do I hate perl?

      Because when I said (1,2, (3, 4)) I really actually truly wanted a nested list, but Perl happily flattens it without warning. (Note: I know about references -- minefields suck even if you know where the mines are).

      Because I am tired of sloppy, legacy syntax like auto-quoting of barewords in some contexts, and the stupid hacks it takes to work around them (like prefacing constants with +).

      Because I want objects and inheritance, not blessed hash references and @ISA.

      Because I want to be able to index into strings with the [] operator, like pretty much every comparable language will let me do.

      Because the fact that ("" eq undef), ("Foo" == "Bar"), and (!"0") all evaluate to true makes me want to eat glass.

      Because evaluating an array in a scalar context is not an intuitive way to get its length. Nor is $#array.

      Because Python and Ruby are so vastly better, and yet Perl is what we're stuck with for the moment.

  25. Re:Is there a point to Perl any more? by jericho4.0 · · Score: 2, Insightful
    Perl is 'hardcore' compared to python. More things to remember, more exceptions to rules, more than one way to do it. Very powerful, but can be intimidating.

    So, if you want a language for scripting 9in the sense that most people with little scripting experience think of it), you might want to avoid perl. If you want a language to elegantly encode brilliant ideas in a short space, go for it.

    --
    "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
  26. Actually, I'd say that by Anonymous Coward · · Score: 4, Insightful

    never using a programming language again due to an argument you had on the internet identifies you as a particular kind of person.

  27. Obligatory by value_added · · Score: 2, Funny

    I still find this funny.

    And still use Perl.

  28. Flame On! by Qbertino · · Score: 2, Funny

    First of all some TLC for you Perl Fanboys (and girls) out there: Everybody loves Perl. Perl is cool, fast, delivers fast results in the area it rules and is the grand daddy of OSS languages. Nearly all books on Perl are fun to read and at least a great laugh.
    In fact it's quite amazing how long this quirky relic of ancient Unix paradigms managed to survive. It's 2005 and Perl _still_ is taken for granted as a PL. That's a terrific feat!
    The only PL in the same demografic group that is still in use is SQL. And everybody agrees that SQL is a pain in the ass and the people who invented it -if still alive - should be wrapped in brabed wire and shot into the sun. Larry Wall on the other hand still is a hero. Perl is fun. Sort of like riding granddads old bike that has no gearshifts and weighs a metric ton. If you tighten all the screws, fill up the tires and give the chain a good greasing you can feel the raw power.

    Yet I choose Python over Perl because of it's better OOP capabilities and the fact that it's code only gets unreadable if you use brute force in making it unreadable. Python enforces good coding habbits making it handy for group projects and n00bs, has a strong foothold in lots of areas where Perl lacks (Gaming, GUI, 3D, large Web frameworks, etc ...) and is the best candidate for a Perl successor. It only lacks Perls unmatched regex features. Entry the famous saying:

    Perl is executable line noise, Python is executable pseudocode.

    However, all academic discussion aside: If you think it's important to be a 'manly' programmer by preferring outdated development habbits over modern and, yes, easyer PLs, you're being silly. Perl being cool or not, there are situations were it is plain irresponsible to use it.

    --
    We suffer more in our imagination than in reality. - Seneca
    1. Re:Flame On! by lupin_sansei · · Score: 2, Insightful

      Well said. I for one am so sick of the "proof by repeated assertion" that python (and ruby) is more readable than perl. Yet nobody ever shows you 2 pieces of code, one in perl and one in python where it is clear that python is significantly more readable.

    2. Re:Flame On! by Chandon+Seldon · · Score: 3, Interesting

      I prefer programming in Perl to Python. This is primarily because Perl has better variable scoping, which combines nicely with "use strict" and "use warnings FATAL => 'all'".

      In Python, there are two scopes for variables: Global and Function. In perl, any { block } gets it's own scope for "my" variables. This means that temporary variables disappear when you're done with them rather than sticking around clogging up memory and name spaces. Because perl has variable declaration statements (my, our), it can check at compile time to make sure you have no typos in variable names. In python, any time you do an assignment you might be declaring a new variable - and you'll never know until you get incorrect output.

      Also, Python has no do...while(). This gives you the amazing choice of duplicating program logic (awesome when you change only one instance later) or putting in a "while 1:" - rather than knowing where the loop condition is, the maintnence programmer gets to randomly guess *and* this opens the way for "sometimes the loop never ends" bugs. Not good times.

      I'm looking forward to Perl 6 where it will be possible to have semi-static typing. That will mean even less code that compiles but doesn't work. I really wouldn't want to be using a language without similar features for any sort of non-trivial software project.

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
  29. Depends by Tony · · Score: 2, Insightful

    Python is for weenies who want to be told how their source code should be laid out.

    Perl is for weenies who want to feel superior because their language can be write-only.

    I prefer Perl, myself. The few times I've used Python, I've hated the enforced layout. It seems like it wants to be a verbose LISP without all the parenthesis, but instead turned into a straightjacket.

    When I've used Perl, I've felt that I'm in a maze of twisting passages, each of them the same (or *mostly* the same). But it's a better feeling for me, having the Swiss Army knife with six screwdrivers, a garment steamer, compass, knife, knife sharpener, nuclear power cell, and fly swatter. Yeah, it's a mess, but it's a *beautiful* mess.

    But, like any cult, it depends on which one you want to join. Me, I joined the one that serves ice-cream on Fridays, because they allow dogs. The decision on which language to go with is almost as arbitrary, and certainly as absurd. Just pick one and code. Or pick both, and code.

    --
    Microsoft is to software what Budweiser is to beer.
  30. Who cares about programming languages? by lmb · · Score: 2, Insightful

    People who still care about programming languages are wasting their breath.

    Look at the difference between a bad, a good programmer and an excellent programmer. We're talking 1 to 2 to 10 factors in productivity and quality here, easily.

    Programming languages? Unless it's a language (or programming paradigm) the programmer doesn't know (in which case it doesn't matter much whether it is Java, C, C++, Perl, Python or ruby) at all, the difference for the same programmer from one to another may exist (depending on how fluent they are), but likely more on the order of 10-20%.

    This is much the same like arguing about indentation and whitespace style. None of the common ones is _significantly_ better than the other, and the time spent arguing about them sure ate up any gains they might have ever offered. Pick one and stick to it, amen.

    So, the choice of language is almost irrelevant compared to the person (or team) you get to do the job.

    For quite some applications, it doesn't even matter whether the interpreter or the compiler is exceptionally fast or produces such code, as long as it gets the job done. (I've seen people tune code for hours, to get it to run 5s faster at a total runtime of 1 minute once per month. While artistically pleasing, it's a waste of time.)

    Sure, there's exceptions to this rule. If you want to write a Linux Kernel module, you're essentially forced to write C. Some languages have either special features in the syntax or many libraries available to solve problems in a specific problem field. (Perl really beats C for writing string matching, for example.)

    But overall, these don't matter as much as you think they do.

    Now, with that said, one exception I'd like to dip into, and why I'm glad that python exists. (Take note I'm a Perl head myself!) Perl allows not one, not two, but several hundreds of ways of doing the same thing. Picking one of the "best" choices to do something is a matter of style, taste and experience. Understanding it is too. So, I'd argue that -good- Perl is slightly beyond the average programmers, because if you had the skills, you'd be at least a good programmer already.

    Python/Java, on the other hand, is stricter. (It starts with enforced code formatting and goes from there.) This, to a free-thinker like myself, often feels like an artifical constraint. _I_ want to decide how to do this, damn it! But, if you want to enable average programmers to just get their small hack in quickly and almost cleanly, Python might not be the worst choice, while Perl might rate pretty low.

    I still love Perl. And Perl 6 looks like a real improvement, surprisingly both in features as well as in style - that is quite a feat.

    End of rant ;-)

  31. Re:No, there isn't. by cloudmaster · · Score: 2, Insightful

    So, did you switch because you never learned to use perl effectively, or because you're such a crappy programmer that you couldn't remember to use a good coding style unless the compiler barfed when you made a mistake? :) Seriously, perl can be complicated, as there's a lot to learn...

    Yes, I'm quite familiar with Python. I prefer perl. My code looks good because I know how to program, not because the language forces me to indent. Changing the name of a hash to a dictionary, an array to a list, and making a distinction between read only arrays and read-write arrays does not make a language better. Replacing semicolons with newlines doesn't make a language better. Removing the ability to coerce types when appropriate doesn't make things better (if I want to treat a number as a string, I shouldn't have to make a big deal about it in a scripting language).

    Granted, I have less experience with python thatn with perl, and that drives lots of my preference. But the only thing I've found better about python is the method documentation scheme. That's marginally neat. Then again, I comment my code in perl, and it works fine.

    Ignoring my rather facetious comment at the beginning, can you actually give me an example of something python does better than perl, other than really large programs (which I don't think python is all that great for, either) or converting otherwise sane people into frothing zealots? ;)

  32. legacy "unreadable" Perl code by fprog · · Score: 2, Insightful

    The problem with any programming language and it's once legacy source code writing style kicks in, this is true for any language, include C, C++ or Perl.

    The older the language is, the more chance that you find some unmaintainable legacy source code.

    The thing with newer language with Python, Ruby,
    PHP, Java and some C++ is that these are "recent" language, therefore, the odds of finding a very old legacy system is smaller.

    In 10-15 years from now, you will say that Python, Ruby, PHP or Java is so "unreadable",
    because they are no more the "flavor du jour"
    and new constructs exists instead. Like most people says about cobol, pascal, scheme, lisp source code.

    There is a difference between "unreadable" and "encrypted".
    The former was not "expecting" to be unreadable, it is just badly written by mistake or use older construct that nowadays are no more used.
    The later was made on purpose, which is the difference.

    If you want "unreadable" C source code, take a look at Graphviz Dot, no it's not part of IOCCC and was not make to be part of it, but if you ever try to understand this legacy code, good luck!!!

    Disclaimer, Graphviz dot is a nice piece of software, but it cries out loud to be heavily refactored.

    In fact, the first two layers were refactored, but the core engine is dated back to the 80's with K&R style and variable/function/struct name being less than 5 characters!

    http://www.graphviz.org/pub/graphviz/ARCHIVE/graph viz-2.4.tar.gz

    If you want "unreadable" Perl source code,
    take a look at any source code, which have:

    no "use strict;"
    no "use vars qw{};"
    use heavily "local"
    use heavily "map"
    no "return" statement --> $r; == return $r;
    use heavily complex non-trivial regexp without documenting them.
    no documentation or POD.
    use some old perl construct.

    Take a look at this one,

    clc (gzip'ed tarfile)
    Counts total lines, noncomment lines, and statements in C/C++ source.
    Written by Brad Appleton in 1995. Implemented in perl.

    http://www.chris-lott.org/resources/cmetrics/clc.t ar.gz