Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Perl Programming

Perl's Extreme Makeover 408

PurdueGraphicsMan writes "There's an article over at Yahoo! about the upcoming version of Perl (version 6) and some of the new features (RFC list). From the article: "Although Perl 5's expressions are the most sophisticated available and aspired to by other programming languages, "no one pretends for a moment that they're anything but hideously ugly," said Damian Conway, a core Perl developer and associate professor at Monash University in Australia.""
This discussion has been archived. No new comments can be posted.

Perl's Extreme Makeover

Comments Filter:
  • Trolling, maybe (Score:2, Interesting)

    by fsterman ( 519061 ) on Thursday February 19, 2004 @06:43PM (#8333115) Homepage
    We might be able to actually use them in ten years or so... I do appreciate Open Source speed (done when done) and Perl is pretty complex but maybe they should have broken the upgrades into parts?
  • by StuWho ( 748218 ) on Thursday February 19, 2004 @06:44PM (#8333120) Journal
    "But Perl also will remain a language with the diehard developer fans who are the impetus behind its popularity. "Personally, I'm hoping to get Parrot embedded into games and office suites," Sugalski said. "I for one would love to write my word processing macros and game scripts in Perl or Forth rather than in whatever hand-rolled language someone's come up with."

    Back to Pac Man and Vi then...

  • Ruby... (Score:1, Interesting)

    by Tyler Eaves ( 344284 ) on Thursday February 19, 2004 @06:47PM (#8333157)
    ...provides almost all of Perls power, with none of the ugliness.
  • by devphaeton ( 695736 ) on Thursday February 19, 2004 @06:49PM (#8333181)
    ...would be able to tell me if i should

    a) start learning 5 anyways

    or

    b) wait till 6 is released, because going from barely having a grasp on 5 and then trying to learn 6 would just confuse myself?

    i realise that all the perl5 code in the world won't suddenly cease function the minute perl6 is released, but still..

    I can see the value in perl, and what a great tool it is, but for some reason i have a hard time wrapping my lil brain around it. It's a bit less "structured" or "consistent" than say C is. I suppose it has to be that way in order to do what it does, though.
  • Perl6? Try Ruby... (Score:0, Interesting)

    by Anonymous Coward on Thursday February 19, 2004 @06:49PM (#8333187)
    Perl 6 is *insane* .. the kind of thing that is either the work of a genius or
    a madman. Or both.

    I used to really like Perl, but these days I'm writing bigger and bigger
    programs using interpreted languages. Perl is *really* getting on my nerves.
    I'm not waiting for Perl 6, I'm writing all new code in Ruby (or Python if
    Ruby doesn't have the needed 3rd-party libraries).

    Ruby is what Perl *should've* been, and what Python will be in a couple more
    versions (it got popular before they finished designing it, it seems).

    I'm sure Perl 6 will be like getting a blow job from Larry Wall himself, but
    I've had enough of Perl's community and their "cleverness". I want languages
    that help me write programs, not that are good for writing haiku in.

    However there are two things I"m looking forward to: 1) better regular
    expression syntax .. I'm sick of "(?:..)" and other confusing add-ons.. and 2)
    a common runtime between perl, python, and ruby, that way I can use all sorts
    of libraries in my code, no matter what the language I happen to be using.
  • by use_compress ( 627082 ) on Thursday February 19, 2004 @06:50PM (#8333194) Journal
    With such bloated and obscure syntax in both the language and regular expressions, why do you think Perl 5 has become so popular? Once you've written a few programs in it, it is ULTRA EASY, ULTRA FAST and not hard to remember. An experienced Perl programmer could probablyl do almost any text processing task in a third of what it would take an expert C++ programmer to do. All of the bloat and lack of orthogonality and "bad design" paradoxically makes Perl 5 a fantastic language to program. I hope Wall doesn't mess this up...
  • Too many cooks (Score:4, Interesting)

    by ObviousGuy ( 578567 ) <ObviousGuy@hotmail.com> on Thursday February 19, 2004 @06:51PM (#8333212) Homepage Journal
    While no one would ever accuse Perl of being single minded and focused, until Perl5 it was a fairly coherent language.

    I understand that Perl6 is supposedly an evolution of the language, but there are so many suggestions for so many features and changes that the language itself seems to suffer from the too many cooks problem. With everyone and their brother suggesting features, the language itself becomes a mish mash of these features without a central theme tying it all together. Even if you said that DWIM was the central theme, can you really justify that when WIM is not what the language does because the feature that I'm using was designed by someone who had a completely different idea of what he meant?

    In the past Perl has added functionality that was useful and you can see where the language has its partitions. Base Perl (datatypes, simple arithmetic, simple string manipulation), nested datastructures, regexes, OO, and so on. While admittedly a mess, each addition to the language brought more power and ease. Perl6, OTOH, seems to be adding feature after feature without regard to whether it makes the language easier to use, only more powerful.

    So you end up with a new interpreter that won't run your old scripts without modifying the scripts. At the very least it should automatically default to Perl5 syntax unless otherwise told to use Perl6 syntax. Unfortunately, in the push to evolve, Larry and Damian (and the rest of the lunatics) have foregone automatic backwards compatibility.

    I'll probably migrate, but not for a while.
  • Hmmm (Score:5, Interesting)

    by Moth7 ( 699815 ) <<mike.brownbill> <at> <gmail.com>> on Thursday February 19, 2004 @06:52PM (#8333226) Journal
    IIRC it's possible to write OpenOffice macros in Perl (Though it probably takes some nasty hacked API to do it). And of course, given how easy it is to embed a Perl interpretter into C apps (possibly moreso with Parrot) then there's really no reason why it can't be used for game scripts.
  • by smack_attack ( 171144 ) on Thursday February 19, 2004 @06:53PM (#8333236) Homepage
    Learn 5, because it will probably take a few months until 6 is standard. Either way, in a few years you will look back on whatever you coded today and shake your head in shame. /used to printf() every line when he learned PHP
  • by FatRatBastard ( 7583 ) on Thursday February 19, 2004 @07:02PM (#8333352) Homepage
    user...

    Is Parrot something akin to the JVM / .NET runtime engine? If so is the plan for it to be as robust as the JVM / .NET runtime: i.e. could the same type of applications that people are building for Java / .NET be just as easily built with Parrot?

    If I'm reading all of this right Parrot may well become everything Sun wants Java to become / MS wants .NET to become without the "what are those bastards going to do to the platform" stench.

    Of course, if I have the wrong end of the stick here I apologise. Perl isn't my strong suit.
  • by x3ro ( 628101 ) on Thursday February 19, 2004 @07:02PM (#8333355) Homepage

    I'm amused to see that the name 'Parrot', originally coined for an April Fool's joke [oreilly.com] over at O'Reilly, has now been used to christen the bytecode interpreter for Perl 6. Life imitating art I guess.

    As for the 'extreme makeover' ... I hope it loses a bit of the excessive punctuation ...

    $broken ? fix($it) : s/!@#\$%\^\*//g if $ugly >= $all_hell;
  • by furry_marmot ( 515771 ) on Thursday February 19, 2004 @07:03PM (#8333363) Homepage
    Because it's a high-level language with lots of sytactic sugar that made a whole new level of flexibility in programming. You can be loose, sloppy, tight, properly formatted, or write one-liners with equal ease.

    I agree with the main topic that other languages aspired to its expressiveness. The problem, from the point of view of a Perl hacker like me, is that some of them have actually outdone it, primarily by creating similar power, expressiveness, and simplicity but without being so ugly *and* being OO. Ruby and Python are pretty much the motivators for the upgrade.
  • by 1iar_parad0x ( 676662 ) on Thursday February 19, 2004 @07:03PM (#8333365)
    Programming with regex in a high-level language is going to be odd no matter the syntax. First-Order Logic is odd. The lambda calculus looks odd. LISP looks odd. Languages that are based on fundamental symbolic operations look odd.

    these regular expressions were not "powerful enough for many data-parsing tasks

    I will be the first to applaud Larry Wall and the Perl developers if they can clean up regex. However, I feel tinkering with a notoriously complex thing may make it worse. Or at best, may make more of an ugly thing. What we don't need is the new unreadable way and the old unreadable way of creating regexes. What fun it will be to debug code.

    Frankly, how can you increase the power of regex and minimize the complexity of code. If you make regexes more powerful, you might as well make another high-level language for text processing. Let's hope they can pull it off.

    Frankly, I for one like the power of Perl's regexes and I hope they succeed.

  • Re:No, Python (Score:3, Interesting)

    by Tyler Eaves ( 344284 ) on Thursday February 19, 2004 @07:09PM (#8333427)
    I used to use python a lot. Still do, really. I like it a lot.
    I just like ruby more. I find it easier to learn, even faster to code in, and language development is just as fast, if not faster than python.
  • by ChaosDiscord ( 4913 ) on Thursday February 19, 2004 @07:10PM (#8333448) Homepage Journal
    Heh. Still, it's worth noting that this isn't new to Perl 6. Perl's always been a Chimera. Quoth the Perl man page (as it has as long as I can remember), "Perl combines (in the author's opinion, anyway) some of the best features of C, sed, awk, and sh, so people famil- iar with those languages should have little difficulty with it. (Language historians will also note some ves- tiges of csh, Pascal, and even BASIC-PLUS.)" As for why being a freakish blend and a giant mess is actually a feature, I suggest checking out Larry Wall's Second State of the Onion [perl.com]. (It's a long page, but the stuff on the advantages of complexity is all near the top.)
  • by GigsVT ( 208848 ) on Thursday February 19, 2004 @07:23PM (#8333609) Journal
    Writing code is easy. Reading someone else's code is the real test.

    I stick to Bash for most things involving text processing.
  • SNOBOL (Score:3, Interesting)

    by Stephen Samuel ( 106962 ) <samuel@bcgre e n . com> on Thursday February 19, 2004 @07:27PM (#8333660) Homepage Journal
    I haven't seen much of the new perl expressions lately, but they're gonna have to be pretty hot to beat what SNOBOL (spitbol) used to do, [google.ca]
    Spitbol could do things like:
    • stringtomatch "this is some text" skipto("(") $ pre_paren ( funcof(pre_paren)$parenmatch = replacement(parenpatch) )
    In this case, the $ is an immediate assignment of the match from skipto("(") (roughly equivalent to /([^(]*)/ . )
    funcof is then called with the newly assigned variable (pre_paren), and it's result is inserted as an expression to complete the match.
    then whatever matched funcof(pre_paren) is replaced by the results of replacement(parenmatch)

    skipto is a builtin, but funcof and replacement would have to be user-defined (and they can be defined on the fly).

    Perl6 appears to have similar functionality, but (IMHO) I don't think it's going to be quite as nice as the SNOBOL syntax.

    Unfortunately, I'm not good enough at compiler design to write my own spitbol interpreter, or I would.

    The one problem with snobol is that it was created before the idea of structured programming came along, so it is goto-structured... (although somebody then came up with ratbol which was essentially a preprocessor to provide RATional structure to snoBOL)

  • Re:Expressions .. (Score:3, Interesting)

    by Gherald ( 682277 ) on Thursday February 19, 2004 @07:35PM (#8333750) Journal
    >> Python enforces clarity

    > So does a man standing next to, you holding a gun to your head, saying "INDENT THOSE BLOCKS!".

    Certainly, but somehow Python doesn't make me feel quite as nervous.

    Besides, there are too many availeability and cost issues with men-standing-next-to-you-holding-gun-to-your-head,
    whereas Python is 100% free, which I've found to be much more convenient.
  • Re:SNOBOL (Score:4, Interesting)

    by Stephen Samuel ( 106962 ) <samuel@bcgre e n . com> on Thursday February 19, 2004 @07:41PM (#8333834) Homepage Journal
    omigod... someone just (yesterday) released an up-to-date version of snobol [snobol4.org] I'm in patern-hacker's heaven.

    Oh, and just to keep on subject:
    SNOBOL is considered to be the parent of unix regexpressions and awk which led to Perl. Unfortunately, the children inherited a much castrated version of snobol's string manipulation capabilities which have only now been reasonably addressed in perl6.
    If nothing else, I suggest that people interested in the history of pattern matching take a good look at snobol.

  • by cliveholloway ( 132299 ) on Thursday February 19, 2004 @07:45PM (#8333882) Homepage Journal
    They're great. They help you to remember and comprehend code you wrote a while back. If you start a line with a "#" you can follow it with a comment.

    If you're looking at code *you wrote* for over an hour without understanding it, you only have yourself to blame. Unless you're coding in brainfuck [catseye.mb.ca], I suppose.

    tch

    cLive ;-)

  • by Anonymous Coward on Thursday February 19, 2004 @08:06PM (#8334092)
    bear in mind that Perl is the first language that I know of that used the foreach construct

    man awk

  • by perly-king-69 ( 580000 ) on Thursday February 19, 2004 @08:18PM (#8334234)
    well, this is quite proper and normal syntax:
    s/(.*?\s+)\(.*?\)/$1/g
    Looks like an explosion in the ascii factory to me!
  • Performance (Score:3, Interesting)

    by sbszine ( 633428 ) on Thursday February 19, 2004 @08:31PM (#8334361) Journal
    As for performance, well, in my experience the slick, hackerish ways of doing things often slow things down more than the explicit-using-more-lines way of doing things.

    Amen. I think this is because the interpreter / VM is usually optimised for the most obvious way of doing things. If you try and improve the performance of your code with tricks and shortcuts, you're basically trying to outsmart the Larry and the other internals hackers.
  • Re:Expressions .. (Score:3, Interesting)

    by Christianfreak ( 100697 ) on Thursday February 19, 2004 @08:46PM (#8334504) Homepage Journal
    Perl is highly modular but I would hate to work in a team of 10 or more perl developers all writing in their own styles and methods. Shudder.

    Its called DISCIPLINE and its not that hard. Someone makes rules for the dev team and then they are followed and then your code is clean and readable. Why should the language force you to be disciplined? Good programmers know to program following some kind of standard.

    And why does everyone bring up PHP? PHP is nothing but Perl with all the best parts taken out and everything thrown into the core language. PHP breaks all the rules of good disciplined programming. With Perl you can shoot yourself in the foot but at least the newbies stay away from it enough to keep the damage to a minimum, and it has controls such as 'strict' and Taint mode so you know when you are shooting yourself in the foot. PHP on the other hand gives the newbies a shot-gun and says 'point this at your head'. PHP coders that actually understand the basics of good programming are few and far between. And trust me there is more than one way to do things in PHP as I've been fixing the problems created by the former 'programmer' in my company for the last year.
  • by raytracer ( 51035 ) on Thursday February 19, 2004 @08:50PM (#8334530)

    Here's an idea: get over it. It isn't that big of deal, and either choice is vastly more readable than perl.

    Let the flames begin!

  • by imipak ( 254310 ) on Thursday February 19, 2004 @10:16PM (#8335392) Journal
    I must be sick in the head or something, but I fell in love with Perl reading the 'Learning Perl v4' llama on the tube in 96 - to me the elegance simplicity and yes beauty of the code really took my breath away. Good Perl code is one of the few things that aren't music that genuinely move me, tickle my aesthetic dangleberries as it were.... I mean... while (){ print; }... *sigh* no really. I'm serious. Granted I was programming in Visual Basic when I fell for Perl - frmo the ridiculous to the sublime really....
  • Re:No, Python (Score:2, Interesting)

    by perlchimp ( 263475 ) on Thursday February 19, 2004 @10:53PM (#8335709)
    There are a lot of reasons but the short answers are regexes and the fact that non-programmers can get started quickly. Plenty of sharp minds think "If I could only sort throw this text and do this...." Perl lets them do that. You'd be amazed at the biology you can uncover with 50 lines of code and 50 megs of sequence. (If they don't 'use strict' though, plenty of comical things can happen.)
  • Re:Expressions .. (Score:2, Interesting)

    by takshaka ( 15297 ) on Thursday February 19, 2004 @10:55PM (#8335725)
    I've seen plenty of poor Perl code, but I wouldn't call any of it unreadable--just bad. Writing truly unreadable code in Perl requires a much higher level of mastery than most people ever acquire.
  • OO Perl? (Score:3, Interesting)

    by nounderscores ( 246517 ) on Thursday February 19, 2004 @11:16PM (#8335894)
    I didn't even know it existed. What books/resources should I read if I'm going to stick with perl 5?
  • by fanatic ( 86657 ) on Thursday February 19, 2004 @11:57PM (#8336164)
    the current Perl 5 compiler/parser/runtime mush.

    But how does eval $string work in a runtime with no compiler?

  • Re:No, Python (Score:2, Interesting)

    by Mr. Pillows ( 745647 ) on Friday February 20, 2004 @01:13AM (#8336699)
    I am a bioinformaticist and I don't use perl that much. I have often wondered why perl was so popular myself. I think a lot of it has to do with the misconception that perl is the only language that works with text files. So maybe I should back up for a minute . . . there a part of computational biology that has to go through the uglies of working with raw data in files . . . thus the need to parse through them and reformat them.

    Almost every language has text processing capabilities. Here's a dirty little secret most people don't know . . . regular expressions for bioinformatics work is not as important as people would like you to believe. The fact of the matter is, most of the data bioinformatics researchers encounter is structured data. Simple string parsing and tokenization is all that is needed. Regulars expressions past the most simple are rarely encountered. In fact, a lot of the data a bioinformaticist encounters is in either XML, tab-delimited, or CSV. For the text processing part of my tasks, I have often used awk to blow my way right through a text file. Of course perl can do the same thing, but I'd like to point out that awk is great when so much of your data is in tabular format (we've got databases everywhere in this field). I also find Java's String, StringTokenizer, BufferedReader and Writer mixed with the FileReader and Writer classes to work great with text files too.

    This brings me to my last point. Perl is horrible for some areas of bioinformatics. A lot of people employed in so-called bioinformatics positions spend like 90% of their day parsing through text files. Most people don't know that there are bioinformaticists who spend very little of their day doing that, but instead are developing algorithms and such that usually require a different language. For instance, I'd hate to run a Hidden Markov modeler with the Viterbi algorithm coded in Perl :) Or how about a massive simulation during haplotype reconstructions in perl? Or maybe a support vector machine in perl? Hee, you get the idea. For these tasks C is often chosen. Particularly if one employs parallel programming. I encourage bioinformaticists to explore other languages besides perl so that they have a vast array of expression for the multi-facted charges a computational biologist is expected to handle.

  • by aiyo ( 653781 ) on Friday February 20, 2004 @03:45AM (#8337489)
    I dont write comments when writing code. I usually come back the next day and add comments. This way I remember what the code does, but also have given my self time to get out of the train of thought I had. Looking back I can more easily see if I have used bad programming style. Sometimes you just want to write the piece of shit and move on to something more interesting.
  • Re:Expressions .. (Score:3, Interesting)

    by mcrbids ( 148650 ) on Friday February 20, 2004 @03:50AM (#8337501) Journal
    Maybe it's just me. But every time I sit down and promise myself to write a new script all tidy and clean in python, about five minutes into it I'm muttering "if this were perl I coulda been DONE by now" and quickly revert back to old faithful.

    Funny. I feel the same way about PHP. It's routine for me to take some broken, busted stuff written in Perl or c or whatever, and redo it in PHP in 1/4 the lines.

    As Jethro Tull once said:

    "You know what you like, and you like what you know".

    I can "do" Perl, but it brings me much grief to do so. While I find PHP consistently readable and understandable, pretty much no matter who wrote it.

    Oh, and BTW, since I've taken the time to "get" regex, I don't even find it ugly. The earlier example about $stuffinParen or whatever was hideous, and not nearly as understandable to me as the simple, concise, original example. Einstein once said:

    "Everything should be made as simple as possible -- but no simpler!".

  • by j.leidner ( 642936 ) <leidnerNO@SPAMacm.org> on Friday February 20, 2004 @08:55AM (#8338427) Homepage Journal
    The new Perl regex notation might be slightly less horrible than the old one, but I think regular expressions are to be rejected altogether, as they make software un-maintainable.

    They should be replaced by something better, such as Xerox' Extended Regular Relation Calculus [xerox.com]: Here [xerox.com] are some examples.

    The nice thing about it is that it's fully declarative and bi-directional, i.e. a:b can be applied substituting a by b or vice versa (if run backwards), whereas the traditional

    if (/pattern/) { action; }
    pattern-action paradigm that Perl has inherited from awk is only partially declarative (only the pattern).

    Another interesting property is that xfst, one of Xerox' compilers, allows naming and re-use of subexpressions:

    define countryCode "++" [0-9]+ ;
    define areaCode "(" [0-9]+ ")" ;
    define endNumber [0-9]+ ("-" [0-9]+)
    define phoneNumber countryCode areaCode endNumber
    (all without any ugly '$'s :-)
    Abstraction by naming is a powerful feature, as Abelson and Sussman (SICP) and other good elementary textbooks point out.

    Maybe anybody wants to volunteed to build something like this into Perl6 instead?

An authority is a person who can tell you more about something than you really care to know.

Working...