Perl 5.10, 20 Year Anniversary 304
alfcateat writes "Perl 1 was released to the public by Larry Wall 20 years ago yesterday. To celebrate, Perl5Porters have released Perl5.10, the latest stable version of Perl 5. Happy Birthday Perl!
Perl 5.10 isn't just a bug fix version: it's full of new features that I'm eager to use: named captures in regular expressions, state variables for subroutines, the defined-or operator, a switch statement (called given-when, though), a faster regex engine, and more. You can read more about the changes in perldelta."
Hmmmmmm (Score:5, Insightful)
I was right... we hit double-digits with Perl 5 before Perl 6 became available... and don't go on about Parrot -- it's not Perl 6. I'll be interested to download 5.10 and see what it can do. The speedier regex engine is going to be a great boon.
Re:Hmmmmmm (Score:5, Insightful)
Re: (Score:2)
Perl 6 is a language specification, remember? It's no longer a single implementation. Anything that passes the Perl 6 suite will be Perl 6, be it Parrot, Pugs, ...
Anyway, we're seeing good progress recently with Parrot. We should be seeing a Perl 6.0.0 alpha "soon" ...
Re: (Score:2)
Re: (Score:2)
Could someone please define "soon"?
Re: (Score:2)
I remember how excited he was because perl 6 was going to be coming out "any day now". This was in 2001. I have been out of the loop for a while, but every time I do a linux install, I notice that perl hasn't hit 6 yet, and I find that slightly amusing.
Re:Hmmmmmm (Score:5, Funny)
You *know* what kind of responses you are asking for when you write something like that don't you....
Re: (Score:3, Informative)
what the FUD (Score:2)
Re: (Score:3, Insightful)
Re: (Score:2)
Re:Hmmmmmm (Score:5, Funny)
Re: (Score:3, Funny)
Re: (Score:2)
I only now realized that there was a pun in my post :)
Re:Hmmmmmm (Score:5, Funny)
Re: (Score:2)
The reason you want a VM is for performance reasons. If you take a look at a high-performance VM like Java's HotSpot VM, it can actually do code analysis while the program is running and then do optimizations on the fly. YARV, which is being developed by the Ruby team, will give Ruby somewhere around a 3x performance increase. I expect to see continued performanc
Re: (Score:2)
My understanding is that the value of Parrot is that you can mix and match code derived from any compiler that targets it. You could have some Python, some Perl, and some Scheme code (eventually) executing together.
Re:Hmmmmmm (Score:5, Interesting)
If Parrot becomes "efficient enough", then hosting Perl, Python and Ruby on Parrot should permit writing programs in a mixture of all three. Python has a very extensive library, but I certainly wouldn't mind having all of CPAN for which to choose as well - or access to Rails, for that matter. (Yes, I know, much of Rails' value is in its elegant fit to Ruby syntax, but I'd still like access from Python. Call me a library pack rat. :-)
For another example of recent interest to me, Perl and Ruby have excellent integrations with GraphicsMagick; Python has Python Image Library (PIL) instead. Why can't I choose the graphics library I want from any of the big three dynamic languages?
Nor would Parrot implementations of those languages need to replace the main implementations to be useful. The JVM has Jython and JRuby, granting access to Java libraries like Swing. Similarly, Microsoft's .NET has IronPython and IronRuby to avoid the much-maligned VB6. Interoperable implementations of Perl 6, Python 3, and Ruby 2 on Parrot would be very nice indeed.
Well, for a dynamic language junkie like me, at least. ;-)
Re: (Score:2)
Knicker-twisting quibblers like to blame Perl for the fact that they need tabs to understand their own code. Perl is excellent for its purpose.
It is, however, ghastly for OOP.
Switch statements are syntactic sugar (Score:3, Insightful)
Re: (Score:3, Funny)
Yeah, and who needs if statements anyway, or a high-level language come to that? Just syntactic sugar, I say we go back to sector-editing ones and zeros directly to the disk. Readability? Pah.
Cheers,
Ian
Re: (Score:3, Funny)
Re: (Score:3, Funny)
Lean on your keyboard for long enough, and you will eventually have produced a valid Perl script. Of course you won't know what it actually does, but then how does that differ from 90% of Perl scripts anyway?
Cheers,
Ian
Re:Switch statements are syntactic sugar (Score:5, Insightful)
Re:Switch statements are syntactic sugar (Score:5, Funny)
2 + 3 == 5 (Perl isn't that weird)
2 + "3" == 5 (not a TypeError as in Python)
"2" + 3 == 5 (not "23" as in JavaScript)
"2" + "3" == 5 (not "23" as in both JavaScript and Python)
Re: (Score:2)
Now, if we look at the equivilent results when using the string addition operator (lets call it <>, to represent + in javascript/python and . in perl):
2<>"3"==type error in python and perl
"2"<>3=="23" in all
"2"<>"3"==
Re: (Score:3, Informative)
Are you sure about that?
$ perl -e 'print 2 . "3", "\n"'
returns 23 on my system (perl, v5.8.8 built for x86_64-linux-gnu-thread-multi). Note you need a space before the dot, otherwise Perl gets its knickers in a twist because a dot looks like the fraction delimiter; but that's OK, because we don't have to strip out unnecessary spaces to make our code fit into the remaining 6KB of RAM (after allowing 20K for the framebuffer and 6K reserved for the system) an
Re: (Score:2)
Actually, perl has overloaded operators too. Now itdoes, anyway. Scalars are a remnant from perl 1, and themselves some sort of throwback to awk.
Re: (Score:2)
Implicit vs. explicit parsing (Score:4, Insightful)
Implicit parsing a num to a string is straightforward and will pretty much always work, even if you may get wierd results like "1.66666666666666666667". But the other way is just too careless to let be implicitly done. You may unexpected errors when for some reason the string you use cannot be parsed, and you may get either an unexpected datatype or a truncated result when a parsed string would not match the other num you add to it (such as int a = x+5 where x is a string "3.5").
Casting from string to number should always be done explicitly, with precise definition of the data type you cast to, and ideally with an error catching block in case something goes wrong. Letting it be done implicitly is a recipe for headache.
Re: (Score:2)
Thus proving that you have never, ever, programmed in Perl. But I'm glad that you can pass these dicta on what dynamically typed languages should and shouldn't do.
For the record: when a string being used as a number can't be parsed, it's 0
Re: (Score:3, Funny)
Let me guess: You like Pascal. The language that, if it was a car, would have only one pedal and two forward gears.
I program in high-level languages precisely because I don't want to have to think about whether something is a string or a number. I have bought an
Re:Switch statements are syntactic sugar (Score:4, Interesting)
(if (> 3 2) 5 4)
which obviously evaluates to 5. But you know what? You can eliminate the if operator entirely if you let > (and any other predicate) return a two-ary function:
(define true (x y) (x))
(define false (x y) (y))
and stuff the arguments into separate functions for deferred evaluation:
((> 3 2) (lambda () 5) (lambda () 4))
Re:Switch statements are syntactic sugar (Score:5, Funny)
>You wrote something accidentally insightful. Look at the following expression:...
Away - away foul Lisp advocate, and darken not my doors again!
Cheers,
Ian
Re: (Score:3, Informative)
Well, most languages have a ternary operator ?:, which allows to get away without if in any situation. In Perl and Python you can do:
Where CASEx is boolean and STUFF_TODOx is some statement. It has to return true in order to halt the search though, so, in general case you have to go for something like
As well as in your LISP example, this is ugly enough to be avoided when
Re: (Score:2)
As well as in your LISP example, this is ugly enough to be avoided whenever possible :)
When used judiciously, it can actually lead to succinct, readable code. Take for instance, in perl, the opening of a file:
open SOME_FILE, ">some_filename.foo" or die("Some kind of error occurred");
Using short-circuit operators like &&, ||, or ?: can actually greatly simplify your code if you don't go overboard with them, particularly if you can call them "and" and "or". Having more than two such statements in one big expression I would say is ill-advised if you ever want to read your code s
Re: (Score:3, Interesting)
And then I'm carelessly skipping over 3 > 2 ? 5 : 4, which is of course the *correct* solution
Re: (Score:2)
BTW, why do you think that defining true and false as functions makes them 'only extremely locally true'? If you have a predicate, the only outcome is either true or false.
Re: (Score:2)
I find if-else statements to be quite sufficient. They might be less efficient when compiled, I'm not sure, but when it comes to the readable code, they're simpler to write and parse most of the time. Conditional jumps of any kind are wasted clock cycle intensive regardless. I suppose I could output the assembly and hand optimise that, I know how to do it (yeah, how sad am I...), but if I wanted to do that I wouldn't be using C in the f
Re: (Score:2)
Re: (Score:2)
Re: (Score:3, Insightful)
Lambda-calculus is in no way high level, it just doesn't happen to correspond to a machine model.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:3, Funny)
Re: (Score:2)
I can't wait Perl 6 anyway especially for their promising new Object oriented syntax (and static types).
Re: (Score:2)
Re: (Score:3, Informative)
C/C++ only allows constants to be used as case values in a switch statement, you can't use a variable as a case label. This allows the compiler to optimise the comparisons based on the numerical value of each constant case label. Performing the case evaluations in different orders, using subtraction and addition and testing against zero can be more efficient than comparison
Re: (Score:2)
Re: (Score:2, Interesting)
Switch statements are syntactic sugar. They're really not needed. Nested if/then/else do the same thing.
They do not! Not only do they increase readability of the code in many cases they do not even generate equivalent RTL. When you do a if-else if-else... you tell the compiler that it MUST check the first condition before the second, a subtle but important difference. What this means to the compiler is that an if-else if-else... must have O(n) complexity!
An switch statement on the other tell the compiler each item is independent of any other (and comparison is generally enforced as side-effect free). This
Re: (Score:3, Funny)
Readability? You do realize this is Perl we're talking about?
Re: (Score:2)
Re: (Score:2)
Since you're manually typing a constant number of cases, the if-else tree has O(1) complexity. Always.
Re: (Score:2)
You might as well say that objects are just sugar for structs with function pointers and isa/super class pointers. And that functions are just sugar for goto.
Grousing about a language feature that makes doing certain classes of operations more robust just tells me you don't write much code.
Re: (Score:2)
There are cases where a switch is simply syntactic sugar (however the argument for improving the readability of code goes a long way), however, implementing a "fall-through" with if/then/else is impossible (it would have to be done as a load if if/then statements that at the end set the variable to be checked so that it passes the next if test); That's just insane, and error prone when you add new items into the list.
Re: (Score:2)
A better way to reproduce fall-through with 'if' statements would be to create a false boolean variable that names the reason for falling through, and set it to true in one or more of the earlier 'if's.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
In lower-level languages like C, though, they become a multiway branch, which, when converted to machine code, results in fewer branch instructions. In C code, a good switch statement, particularly in a block of code that's already looped or gets called often, can save you a lot of pipeline flushes.
In high-level languages of *course* it's syntactic sugar, since there are some languages sophisticated enough to convert serial if/elsif/else blocks into multiway branches. Perl is all about that sort of thing t
Re: (Score:2)
There is no other language where pointer to function can be used with such ease.
Aren't these two unrelated events? (Score:2, Insightful)
I can't see why (in purely practical terms) it's worth coordinating a release with an anniversary.
Surely if the code is "ready" (thoroughly tested etc) before the anniversary, it could very easily be useful as a release to developers before the anniversary.
If it isn't ready, it shouldn't be released early just because there's an anniversary.
Re:Aren't these two unrelated events? (Score:5, Funny)
A programming language used for poetry.
A programming language where "bless" is a basic operation.
A programming language which borrows the "understood" syntax from English.
A programming language where all published examples contain variables "Foo" and "Bar".
Of course they are going publish a new release on the twentieth anniversary. I dont think it occurred to anyone in the perl community not to.
Channeling Jeb Magruder, are they? (Score:2)
Original source [washingtonpost.com].
A language where bless is a basic operation (Score:2)
(Yep, I really did hit an executing program on the first try. I think it evaluates to null for all input strings but $_|&%.$# if I'm going to try to parse Perl code without getting paid money for it.)
Re: (Score:2)
Just imagine what will happen when Python turns 20...
...laura
Re: (Score:2)
Re: (Score:2)
Actually, Perl 5.10 has been in release candidate state for a little while now, and someone recently just happened to drop an email reminding p5p of the upcoming anniversary and how cool it would be to release on the anniversary date, so it became a target to get the final out on that date. Without the anniversary to shoot for, it probably would've been a few days later. The fact that the anniversary happened to fall somewhere in the right vicinity was pure luck.
Re: (Score:2)
Spooky.
Re: (Score:2)
There, fixed that for ya. ;-)
Is this the version (Score:3, Funny)
Re: (Score:2)
Re: (Score:3, Funny)
For the younger among you this was a fiendish COBOL construct which altered the
target of a plain "go to" somewhere else in the program. A wonderful tool
for sadists whith a particular dislike of maintenance programers.
Re: (Score:2)
Re: (Score:2)
Re: (Score:3, Funny)
This is Perl we're talking about here. It would be "orels"
Re:Is this the version (Score:5, Funny)
Oh dear. (Score:5, Funny)
*sigh* Nice to see they're still adding to the elegance of the language
I wonder if threading actually works in production yet?
Re:Oh dear. (Score:5, Funny)
Not to mention the new "lol()" built-in, which is like say(), but also removes random letters from the string, and appends 17 exclamation points.
Sometimes I wonder about Larry Wall.
Re:Oh dear. (Score:5, Funny)
Re: (Score:2)
my vote goes to a hello_world() builtin ... (Score:2)
Re: (Score:2)
Sorry, but that has to go to HQ9+ [biffle.org]
Re: (Score:2)
say() is a fairly pragmatic addition to the language. Do you have any idea the percentage of "print" statements in existing perl code which end in "\n". And how often that "\n" is the sole reason to use interpolating quotes and/or an append operator in the print statements (eg: )? It's a high percentage and a pain in the ass.
Re:Oh dear. (Score:5, Funny)
recursive patterns (Score:5, Funny)
Re: (Score:3, Insightful)
Yeah, I saw recursive patterns and thought, "Crap, now I'm going to have to relearn how to look at regexes so that I see those too." Still, I'm excited about the power (while being daunted by the readability).
Much Thanks to Mr. Wall (Score:5, Insightful)
Re: (Score:3, Insightful)
Re: (Score:2)
You'll also be much happier if you start using DBIx::Class instead of pure DBI; it's the best object-relational mapping I've found in any language thus far.
Re: (Score:3, Informative)
The flexibility isn't just CP
New perl additions more than whole of c++ (Score:2)
Favourite quote (Score:2)
Features and whatnot. (Score:2)
Do we really need the "defined-or" operator? Is the "given" operator really any simpler than the numerous known switch examples? Recursive Patterns? My head almost asploded parsing the example. Stop doing things, just because you can. Do something else -- and I don't mean that franken-project Perl 6.
Ok, no more coffee for me today. :-)
Bold perl hackers, I salute you (Score:4, Funny)
Re: (Score:2)
Anyway, the formal version number is 5.010_000.
Re: (Score:2)