Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×

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."
This discussion has been archived. No new comments can be posted.

Perl 5.10, 20 Year Anniversary

Comments Filter:
  • Re:Hmmmmmm (Score:3, Informative)

    by Ed Avis ( 5917 ) <ed@membled.com> on Wednesday December 19, 2007 @10:42AM (#21751226) Homepage
    I think the Perl hackers want something to run Perl 6 on, and the existing perl5 interpreter isn't up to the job (it is fast and well-tested, but the internals are somewhat kludgy). So they need to write a VM. The idea of running Perl, Tcl, Python and others on the same VM is a good one, it would be nice if the world could live together in harmony and all work on the same underlying interpreter, but I don't think the Python or Tcl maintainers will be interested. Which is a shame.
  • by beuges ( 613130 ) on Wednesday December 19, 2007 @10:45AM (#21751262)
    Switch statements are more efficient than nested if/then/else, at least in C/C++ (I dont use perl so I'm not sure if the same applies).

    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 to each value in turn.

    So, a switch statement can be more efficient than nested if/then/else.
  • by SolitaryMan ( 538416 ) on Wednesday December 19, 2007 @11:37AM (#21751782) Homepage Journal

    Well, most languages have a ternary operator ?:, which allows to get away without if in any situation. In Perl and Python you can do:

    (CASE1 and STUFF_TODO) or (CASE2 and STUFF_TODO2) or ...
    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

    (CASE1 and (STUFF_TODO1 or 1)) or (CASE2 and (STUFF_TODO2 or 1)) or ...

    As well as in your LISP example, this is ugly enough to be avoided whenever possible :)

  • by ajs318 ( 655362 ) <sd_resp2@earthsh ... .co.uk minus bsd> on Wednesday December 19, 2007 @12:55PM (#21752858)

    2<>"3"==type error in python and perl
    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) anymore. And Python throws an error for "2" + 3. That's correct, strictly, but it goes against the Principle of Least Surprise (Perl gives you 5, which is both correct and Least Surprising. JavaScript gives you "23", which is neither correct nor in accordance with the Principle of Least Surprise).

    Anyway, my point is that where there is an addition sign, there should be addition (and if a string has to be converted to a number, so be it; don't throw an error unless it's NaN. And provide a mechanism whereby NaN values can be silently treated as zero).
  • Re:Hmmmmmm (Score:2, Informative)

    by chromatic ( 9471 ) on Wednesday December 19, 2007 @06:49PM (#21757808) Homepage

    what is in it for me? Why should I care?

    Having access to the CPAN from other languages would be useful (Ruby programmers take note). I want Pygame and Pyglet available to Perl 6 as well.

    If I'm PHP, why should I compile to PIR?

    Library support, primarily. mod_php is well-understood and widely deployed. However, it's possible that the Parrot security model may make mod_parrot more appealing to deploy than mod_php.

    What is the fundamental "unit" of a library/application compiled in PIR. In .NET you deal in assemblies. In PIR, what do you deal in?

    There's no real formal name, but a PBC file is as close as you get. It's just a bunch of bytecode. As yet we haven't decided on any formal interface that it needs to support.

    Where is the boundary between something written in PHP and something in Perl? Is it a function? A class? A module?

    It can be any of those. For example, my little Scheme-like language has self-hosted tests. They use a testing library I wrote in PIR. The testing library provides a series of multimethods that my language can call as if they were native functions -- and my language doesn't support multi-dispatch!

    How does PIR handle the clash between objects and classes? Can I pass a blessed object created in perl to my PHP app?

    Yes. The semantics of how that object will behave depends on its class, but as long as PHP on Parrot and Perl on Parrot use Parrot's calling conventions and its PMC interfaces for things like calling methods and creating objects, each language can have its own special semantics and can use objects defined in other languages.

    What about namespace issues and how does PIR reconcile against language that have piss poor namespace support like PHP?

    Each high-level language has its own top-level namespace. I imagine that the PHP implementation just lobs some three-thousand functions into that namespace, where Perl 6 stores things differently.

    What about all the cool hashtable/hashref stuff that perl has? How will that work on something like PHP?

    Data structures created in Perl and passed into PHP will have Perl semantics for all equivalent operations performed in PHP. If PHP supports a keyed lookup operation, Parrot will perform that operation on the data structure. How that structure's underlying object handles keyed lookup is up to the object, and it'll have Perl semantics.

    What about inheritance? Can I derive a class in perl from a class written in Ruby?

    Yes. (I don't know how well that works right now; I don't know if anyone has specifically tried it.)

    What about debugging? If something chokes in my PHP library, will parrot let me see the PHP symbol table AND my python symbol table?

    As long as the debugger knows about Parrot, it should.

    How will any of this be useful without a very smart IDE? It is hard enough to keep track of large applications written in Perl because of the lacking tool support. If I'm calling a function/assembly written in PHP, am I now going to have to hop between to languages to figure it all out?

    Reconstructing a language from PBC is non-trivial, but one of the goals of Parrot (and Perl 6) is to encourage better tool support by making it easier to plug an editor into the VM somehow. The answer is "it depends".

    What is the baseline "your language needs to support XYZ before it works in PIR"? Or is this thing so low, the only thing I can bank on is a string? Does it define, for example, how and when a string might get cast as an integer

  • by mr_mischief ( 456295 ) on Wednesday December 19, 2007 @06:50PM (#21757814) Journal
    It's more expressive in that it takes less syntax to achieve the same result than most other languages. I think that's a fairly common definition. Python and Ruby have the advantage of coming after Perl, and Ruby is actually the designer's idea of re-imagining Perl to be more regular and better at OO. They are more expressive than many other languages, too. C and C++ are not nearly as expressive as Perl. They can express the same programs, but it takes much more syntax to do so.

    The flexibility isn't just CPAN, although that's a good thing. It's in the ability to express the same program in more than one way, too. That flies in the face of orthogonality, but orthogonality is a means and not an end. In Perl one can write a functional program, a procedural program, an OO program, or a largely declarative program. One can even use an OO module in a procedural program or a procedural module in an OO program with little hassle.

    Perl has bindings into OpenGL, SDL, Qt, GTK, Tk, WxWidgets, and Motif. That is doesn't have a standard GUI binding is kind of sad, but it has lots of bindings from which to choose.

    The language being more flexible and the end product of a program written in the language being more flexible are two very different things. A program written in Perl can be very rigid and inflexible, while a program written in RPG could be, at great difficulty to the programmer, fairly flexible. The difference is that Perl makes it easy to make the program you're writing either rigid or flexible.

    While it's true that any Turing-complete language can in theory produce the same program as any other Turing-complete language, you've got to be kidding if you think 70 lines of COBOL vs. 10 lines of C vs. 3 lines of Perl means they're all equally expressive. Expressibility and expressiveness are not the same thing.

Living on Earth may be expensive, but it includes an annual free trip around the Sun.

Working...