Slashdot Mirror


Apocalypse 5 Released

Simon Cozens writes "The Apocalypses are Larry Wall's explanation of the design of Perl 6. In Apocalypse 5, Larry turns to redesigning regular expressions. He set out to intentionally 'break' a lot of the regular expression culture we're all used to, and these are the results - and they're mindblowing."

24 of 234 comments (clear)

  1. Regex by inflex · · Score: 4, Insightful

    Why do we always have to keep changing regex [and many othe things]. Isn't enough that we have to learn one format for almost every language. Sure, there are perhaps easier ways to express certain logic situations, but over all, do we /need/ another regex format?

    1. Re:Regex by joeykiller · · Score: 3, Insightful

      Perhaps we need to change regex and a lot of other things because the way they work today is not too optimal, or even logical (not that Perl itself is) or intuitive.

    2. Re:Regex by jaffray · · Score: 5, Informative

      Yes, we do need another regexp format. Larry spends several pages explaining why, if you'd read the article.

      Furthermore, 80% of your existing Perl5 regexps will work unchanged in Perl6. *, +, *?, +?, (), ?, all unchanged. Most of the backslash-letter character classes, unchanged. Dot and ^ and $ are the same for most purposes, trivial to port when they aren't. 80% of the remaining cases can be ported by changing [] to <[]> and escaping spaces or replacing them with \s or \h (which they often should have been anyway).

      I'd rather spend half an hour every fifteen years to learn something new than put up with the inferior old scheme for another decade or more. Unreadability of regexps is one of the biggest complaints people have about Perl, and this addresses those concerns head-on.

      (Incidentally, people made all these same complaints the last time Perl changed regexps, when Perl5 came out. And now virtually every other popular language has recognized that the Perl5 design is better than its predecessors, and has adopted a Perl-compatible regular expression syntax or library. Larry's got a pretty good track record here.)

      (BTW, the preceding incomplete post was a slip of the mouse. Mods, please kill it.)

  2. Breaking expressions by somethingwicked · · Score: 4, Funny

    He set out to intentionally 'break' a lot of the regular expression culture we're all used to

    I hope he can break "Don't go there" and "Talk to the hand" There are many others, but this would be a good start

    --

    ---"What did I say that sounded like 'Tell me about your day?'"---

  3. Apocalyptic numbering by distributed.karma · · Score: 4, Funny

    So, when Perl 6.final is released, will the release notes be called "Apocalypse.Now"?

    --

    --
    If you moderate this, then your children will be next.

  4. New regexes by Dacmot · · Score: 5, Insightful

    The new perl 6 regexes are crazy. They seem "weird" and awkward compared to the perl 5 ones... but then again I thought the same when I started learning perl (at version 5.6).

    A lot of this makes a lot of sense however, especially the default /x to allow for easier reading of code and allow for comments inside the regexes. Some of the new features make the regexes a bit longer to type, but in general they are significantly smaller. There's also a much better and more consistent use of different types of brackets. Not having to look at the end of the regex to understand the whole thing is going to be great. I hate having to skip the regex to look a the flags first.

    Brilliant I think. I can't wait for it to come out. I hope they make a perl5->6 translator though :o) I also wonder what the speed of the interpreter is going to be like compared to perl5. Hopefully faster :o)

    Good job Larry, Damian et al.

    1. Re:New regexes by RevAaron · · Score: 3, Funny

      If you ask Wall, he says that it looks like garbage because it's more "natural," and in alignment with "how we think." If perl is the most efficient way to express the way Wall thinks- be afraid. Be very afraid. :)

      --

      Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
  5. Just what Perl needs by 00_NOP · · Score: 3, Funny

    Something to make the code that little bit more unmaintainable. That keep those PHP whores on their toes :->

    1. Re:Just what Perl needs by GoRK · · Score: 3, Interesting

      Hmm PHP. Talk about a language that breaks things between versions! #include behavior was changed between two revision numbers!

  6. Perl's had it's day - It's become like COBOL by ajm · · Score: 3, Interesting

    For instance there is now OO COBOL but the only people that use it are COBOL programmers who are stuck, perhaps because of their company's dictates, perhaps by choice, with COBOL. In the same way perl may be heading towards irrelevance wrt "mainstream" language. I've written commercial perl in the past, it was a pain then and it's still a pain now. The thing is that now there are alternative languages in the same space (python, ruby etc., php for web side) that do the "perl thing" better than perl.

    Perl was great, it introduced many people to programming, just like COBOL did. But now it's time to move on. To move on to languages that learnt from perl, that improved on it, that don't have to drag around a syntax and culture that values neat tricks and trying to guess what the programmer really meant over providing the needed building blocks and letting you build code that does what you say, not what it thinks it heard you say. Or even, dare I say it, to move on to languages outside the perl family for some programming and choose the right tool for the job for a change.

    I'd prefer to think of this as provocative rather than a flame, there is a difference you know.

    1. Re:Perl's had it's day - It's become like COBOL by kisrael · · Score: 3, Interesting

      As a developer who has done a reasonable amount of Perl and Java, the choice of when to use one or the other is becoming more and more interesting.

      Sometimes, it's just a matter of environment: the places I host my websites have Perl available, (sometimes Java, but it's more of a pain) so that tends to be my first choice.

      There's a lot to be said for the convenience of Perl. Edit code, save, and run has benefits greater than you'd expect by just seeing that edit, save, compile, run is one extra step. (And pushing that one step further, the sheer # of files is one of the things that's a huge drawback to EJBs...)

      And of course there's what the language makes simpler. I know there are Java classes that give it full Perl regexes and the like, but somehow they seem evil to me. I don't like to go crazy with the Perl syntax shortcuts, but being able to so easily open up files and the like, and not have to jump through hoops to read a line at a time...there's a lot to be said for that.

      On the other hand, OO in Perl is pretty disgusting to anyone who grew up with objects in C++ and Java. It even makes PHP's object syntax look normal.

      So, in the end, I don't know. It certainly seems easier to sell my Java skills in today's ugly jobmarket, and it certainly seems easier to update my personal websites in Perl. For now, I guess I'll be keeping up my skills in both.

      --
      SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
    2. Re:Perl's had it's day - It's become like COBOL by Saint+Nobody · · Score: 3, Insightful
      For instance, Python already has changed regexes; but because they don't come built in to the main language syntax (as they shouldn't; not everything is about text), it was a painless transition for everybody involved.

      perl is the practical extraction and reporting language. that's what it was originally designed for, and it's still extremely useful for that. just the other day i had to rip some statistics out of the debug output of a program, and average it together over multiple tests, outputting it into comma separated values. perl was incredibly useful for that. not everything is about text, but perl is designed for the cases where it IS about text.

      perl only really starts to fail when you consider it a panacea. it will not do everything for you, and there's some things that it just plain sucks at. all languages are the same way -- they have strengths and weakness. perl will extract your data, and it will act as a quick scriupting engine, for when shell scripting just isn't powerful enough. just don't try to write an officew suite or anything in it.

      --
      #define F(x) int main(){printf(#x,10,#x);}
      F(#define F(x) int main(){printf(#x,10,#x);}%cF(%s))
    3. Re:Perl's had it's day - It's become like COBOL by ekidder · · Score: 5, Informative

      We use perl pretty much exclusively for my work (telecommunications company). It's not that we have inertia (in fact, the company standard is Java - ack), it's that we LIKE perl. It has the right combination of features that makes just about everyone in the group happy.

  7. Re:People use COBOL by ajm · · Score: 3, Insightful

    I agree, I've used COBOL myself. For what we were doing with it when we were doing it it was the best choice, in fact probably the only choice. That's not the case anymore, just like it isn't with perl. I can see why you're sticking with COBOL, though I'd look at Java as it's probably now the data processing language of choice. I wouldn't rate perl as highly as COBOL wrt its fit in its space anymore. As to Java's maturity, I think you're under rating it pretty heavily. It's mature enough now. btw I imagine you're shop will never use .NET if maturity is a criterion, and rightly so.

  8. Great by duffbeer703 · · Score: 5, Insightful

    So now Perl regexs are going to be completely different from every other language and more complex than ever... wonderful.

    I certainly hope that someone is going to be maintaining Perl 5. I certainly cannot see the Perl community moveing en masse to Perl 6, or whatever they decide to call it.

    --
    Conformity is the jailer of freedom and enemy of growth. -JFK
  9. One thing that I'd like to hear about with this... by AltGrendel · · Score: 5, Funny

    ...is if Cmdr Taco is going to upgrade slashcode to Perl 6 and what he thinks of all this re-write of Perl.

    --
    The simple truth is that interstellar distances will not fit into the human imagination

    - Douglas Adams

  10. Doesn't anyone else find it ironic... by Second_Derivative · · Score: 3, Funny

    ...that the active half of this Perl (5) powered site is completely screwed up at the moment? Improve languages all you want, it's still no substitute for decent sysadminning ;)

  11. Free the regexes! by riffraff · · Score: 3, Funny
    I Like this paragraph:


    However, I would like to think that there is some happy medium between those two extremes. Coming from a C background, Perl has historically treated regexes as servants. True, Perl has treated them as trusted servants, letting them move about in Perl society better than any other C-like language to date. Nevertheless, if we emancipate regexes to serve as co-equal control structures, and if we can rid ourselves of the regexist attitudes that many of us secretly harbor, we'll have a much more productive society than we currently do. We need to empower regexes with a sense of control (structure). It needs to be just as easy for a regex to call Perl code as it is for Perl code to call a regex.


    We've been discriminating against the poor regexes for too long. We need to represent them who are unable to represent themselves. Stop Regex Exploitation Now!

  12. Re:Changing regular expressions? by tjwhaynes · · Score: 3, Informative

    I hope somebody's going to write some automatic conversion tools because going back to one even a few days later is a hairy experience indeed.

    Guess you haven't seen txt2regex? It doesn't support Perl 6 yet - but it supports about 20 languages at this point so I think you can reasonably expect to see more in the future :-)

    Cheers,

    Toby Haynes

    --
    Anything I post is strictly my own thoughts and doesn't necessarily have anything to do with the opinions of IBM.
  13. Will perl6 = ruby? by Jeppe+Salvesen · · Score: 3, Insightful

    I've asked this elsewhere. Ruby was designed with respect to perl, but all the same keeping to the principle of least surprise (which perl does not adhere to). Now, with Perl starting to look like a grown-up, mature language, what will the major differences between Ruby and Perl be?

    --

    Stop the brainwash

  14. recursive regular expressions by Saint+Nobody · · Score: 3, Interesting

    this guy has been doing some interesting work on the regex engine. he's added functionality so that you can have recursive regular expressions without the clumsy postponed subexpression ("(??{...})") mechanism. on the one hand, it's far less readable that way, but on the other hand, you don't have to predeclare a variable for every production rule in your grammar.

    and the current system is even more convoluted since the postponed subexpressions are evaluated in the environment in which they are checked, not where they were declared. this means that all variables referenced when you built the regex have to be in scope when you use it. that's a restriction i'd like to do away with, although i'd rather see it done by making postponed subexpressions support closures.

    as i recall there's also an rfc for perl 6 on the perl site to make a stack-based regex engine rather than stat-machine-based, so that it could support CFGs, but i don't think it specified how it would work syntactically.

    --
    #define F(x) int main(){printf(#x,10,#x);}
    F(#define F(x) int main(){printf(#x,10,#x);}%cF(%s))
  15. Perl parsing Perl by dannyspanner · · Score: 4, Interesting

    I've read comments by Larry to the effect that Perl is great at writing lexers but not parsers. If you look at some of the later examples (around page 11) it's clear that he's trying to make Perl regexes powerful/clear enough to parse Perl. They remind me of yacc/bison, which makes sense.

  16. Dammit Larry ... by scrytch · · Score: 3, Insightful

    Just get the damn thing written, make it flexible enough for us to rewrite perl in perl, and kick this lazy-ass camel out the door before my grandchildren ask me when perl6 is coming out!

    I don't want more powerful regular expressions. I want a more powerful pattern-matching syntax, one I can compile down to an opaque object with a bit of syntactic sugar, then use in place of a regex. I want a parser sub-language like SML or parsing primitives like haskell. Regular expressions are now turing complete thanks to perl ... great, so move on already, regexes are not the final word in pattern matching.

    And what's more -- all this you're doing Larry, it's anti-hacker. It's top-down, it's engineered, it's ivory-tower theory that might sound neat and no matter how zany your presentation is, you are living in the rareified atmosphere of a language designer, and now you are starting to think that way, dispensing wisdom on The Right Way To Do Things from on high. Yes, inventing Just The Right Way to give people 1E+255 ways to do things is still looking for the perfect that's the enemy of the good, because once we have the foundations to improve on perl6, we will do it, but only if we have something to work with. It doesn't all need to be done up front.

    Your extended regexes can be done as a library solution. Stop ending the world and start living in it.

    --
    I've finally had it: until slashdot gets article moderation, I am not coming back.
  17. Perl gives you by nullard · · Score: 4, Interesting
    Perl IS awkward and crazy. I've never understood the attraction to it. The few times I've had to dabble it in, it's just been frustrating, limiting, and ugly as hell. Bleh. I wish someone could explain it to me.

    It's not that perl is akward. It's a language that lets you code in a number of different styles. It gives you the freedom to code your own way. This does reduce readability, but it greatly increases speed of coding. If others need to read your code, just set up style guidelines.

    I use perl for just about all scripting I do on my system. Just a moment ago, I had to read an html file over http, but there were no line breaks. I just needed to get one piece of information, so I did this:
    GET url|perl -ne 's/</\n</g ;print;'|less
    Sure it's unreadable, but it did the job. If I'd been writing CGI, I would've been more verbose since terse perl code can be difficult for even the author to understand by reading it.

    perl gives you lots and lots of freedom. This is not a bad thing, but it is dangerous. Other languages force you to work in one way.

    Think of a bike. A bike w/ trainig wheels makes it hard to fall over, but your agility is reduced. perl has no training wheels by default. You can write really nasty code that works but is unreadable. Perl is anything but limiting.

    If you want more structure to protect you from yourself, try running perl the -w option and put "use strict" in your scripts. If you want pretty built-in identifiers, try "use English"

    I've been coding for so long that the restrictions built into many other languages just get in my way most of the time. I like the way perl never gets in my way.
    --


    t'nera semordnilap