Slashdot Mirror


What's New in Perl 5.6.0

Simon Cozens writes "I've written a summary of what's new in the 5.6.0 release of Perl for this www.perl.com article. " The article does a good job of evaluating what's come out - worth reading if you're a Perl Monk

45 of 125 comments (clear)

  1. Re:PERL FUTURE FORTH FUTURE = QUESTION by William+Tanksley · · Score: 2

    The number of perl programmers is so comparably high, that categorizing them and comparing them to Forth programmers is also probably a waste of time.

    I have to admit the utter and complete truth of this. In fact, in spite of the fact that I _did_ do some comparison (blush), the main thrust of my little essay was to point out that the comparison was inaccurate.

    As an engineer, I can say with certainty that most engineers have never heard of Forth.

    Most engineers have never heard of Java, so this is no big deal. (Of course, I'm not counting computer scientists as engineers ;-). I wasn't claiming that engineers were converting to computer programmers en masse because of Forth; I was merely claiming that Forth use in engineers is MUCH higher than Forth use in computer scientists. Engineers also tend to wind up *liking* Forth, perhaps because it gets less in the way, or perhaps because they would be good programmers but never bother to learn any other language.

    -Billy

  2. Re:Feature bloat in Perl by pudge · · Score: 2

    Eh. References are complicated, but if you read MJD's perlreftut manpage (he is the one who wrote the sins of perl article you reference), they can be pretty easy, I think. They are also very powerful. Also consider that almost all beginners don't need to use them for anything.

  3. Re:Feature bloat in Perl by pudge · · Score: 2

    Creating a new usable class is a hassle?

    package My::Class;
    sub new { bless {}, __PACKAGE__ }

    All done! What else do you want? How about an accessor?

    sub foo {
    my $self = shift;
    $self->{FOO} = shift if @_;
    return $self->{FOO};
    }

    Now we use it:

    my $obj = new My::Class;
    $obj->foo('bar');
    print $obj->foo;

    It doesn't seem that hard to me.

  4. Re:Well _I_ happen to like Perl. by otis+wildflower · · Score: 2

    and scope Scope SCOPE!!!


    #!/usr/local/bin/perl -w
    #

    require 5;
    use strict;

    my ($global0, @global1, %global2, $debug);

    # then do what you were gonna do...


    (note to /. dev crew: please fix Preview HTML tag persistence!)

    Your Working Boy,

  5. Re:Feature bloat in Perl by jbert · · Score: 2

    I stand by the claims - I think its a miscommunication between us.

    Steep learning curve => lots to learn before you can be productive.

    Long learning curve => lots to learn in total.

    Perl is easy to use to start being productive. You can get a lot done with a few features. Many perl coders just do open/close/read/write/simple regexp and are happy. You don't need to know the API to sockets unless you need to use that functionality. I don't see how C lays out a path for you to do that in a way which perl does not. In fact you get docs with a perl installation which you don't necessarily with a C compiler.

    I'll rephrase. Yes, there is a shedload to learn in total, but that can be a gradual process which you need never complete - more gradual than with compiled languages.

    And here are highlights my final final paragraph again, with emphasis.

    Perl is not a *panacea*[1]
    ...use "a good enough tool..." which is *often*[2] perl.

    [1] - solution to *every* problem
    [2] - often. Not always.

    Hope that clears up the contradiction.

    You are right that if I had the attitude "learn just one tool, use it always" then I would be a silly person. "I've got a hammer, that'll get those darn screws in". Thats dumb, no argument.

    To stretch an analogy, I would perhaps say that instead of carrying around a set of socket wrenches, a saw and hedge clippers I'll just carry this natty little combi-tool with adjustable wrench and cutting accessories.

    OK, so I still need to go to the tool shed if I want to cut a tree down, but I have a tool to hand which covers 90% of my needs in one package. Cool. Its why leatherman tools are popular. Same reasoning applies to perl (the 'swiss army chainsaw' gag is tries to get this across). It doesn't remove the need for other tools entirely, but it does cover a lot of cases.

  6. What about '0' in Unicode? by jeroens · · Score: 2

    Some theoretical point here.

    I use perl a lot in everyday's work to do checks and first-round computations on my datafiles, that I aquire in ASCII text.Everything fine with that unicode, but what happens to my zero? Is it automatically translated into a multi-byte Unicode character, and so definitely not a number zero anymore?

    To explain my problem, look at this filter:
    while ([]) { //prints only lines with col3 nonzero to tab-seperated cols; [] means diamond here
    @line=/(\d)+, +(\d)+, +(d)+/;
    if ($line[3]) {print join(/\t/,@line)."\n";}
    }
    I often have to make filters like these, many ad hoc. Does the unicode support make me to change my coding style, that means, translate a zero-character to zero?

    Only theoretical this problem, 'cause I can use those tr// kind'o' codes and more so, because textfiles aren't read in unicode but plain ASCII instead. But anyway, I still like to know how this zero character works...

    Thanx,

    Jeroen

    --
    Writing about music is like dancing about words - FZ
  7. Re:The Camel Book by HomerJ · · Score: 2

    Nope.

    Perl is Perl, expecially for what the Camel book covers. That book will be the staple of every programing library for years to come =)

    It's the same as you can go out and get a 5 year old book on C and start. The basics never change. And alot of the info in the camel book actually refers you to sepecific perl man pages, so some of the information it refers to is only as out of date as your man pages are.

    So needless to say, your money is still well invested.

  8. Should be. by zCyl · · Score: 2

    Leibniz, written in Lisp *spit* uses a complicated recursive pattern matching function to accomplish symbolic calculus through a lengthy ruleset. Since perl natively supports this kind of pattern matching now, it should be elementary to write a symbolic calculus engine in perl, or even to port Leibniz.

  9. Re:Well _I_ happen to like Perl. by orcrist · · Score: 2

    My biggest gripe with perl is that there seems to be no mode to require variables to be declared beforehand. I really despise when I'm coding and do something like:

    my ($fileName) = "/etc/blah/blah.cfg";
    if ( $filename =~ m~^/etc~ ) { print "This is in /etc\n");


    add this at the beginning:

    use strict;

    and you get this:

    Global symbol "$filename" requires explicit package name at /home/ku02c/junk.pl line 4.
    syntax error at /home/ku02c/junk.pl line 4, near ""This is in /etc\n")"
    Missing right bracket at /home/ku02c/junk.pl line 4, at end of line
    Execution of /home/ku02c/junk.pl aborted due to compilation errors.

    Oops, let's correct your bracket ;-)

    use strict;
    my ($fileName) = "/etc/blah/blah.cfg";
    if ( $filename =~ m~^/etc~ ) { print "This is in /etc\n";}

    new output:
    Global symbol "$filename" requires explicit package name at /home/ku02c/junk.pl line 4.
    Execution of /home/ku02c/junk.pl aborted due to compilation errors.

    Try: perldoc strict for more info.

    Happy?

    Chris

    --
    San Francisco values: compassion, tolerance, respect, intelligence
  10. Re:Umm... by EricWright · · Score: 2
    Of course there's more than one way to spell it... Why not Practical Extraction And Reporting Language? Cause Larry didn't want it that way, and it's his project. 8-P

    Eric

  11. Re:Well _I_ happen to like Perl. by Imperator · · Score: 2

    Begin every script with:

    #!/usr/[local/]bin/perl -w
    # -W is highly recommended for v5.6 and upwards
    use strict;

    It might not be ideal for one page scripts you throw together, and it might negate many of the messy constructs we all love (e.g. "push @doesnt_exist_yet $value"), but you'll catch a fair number of errors at compile time and more at runtime that might otherwise have been mysterious errors.

    --

    Gates' Law: Every 18 months, the speed of software halves.
  12. Re:Redundancy mistake by Abigail-II · · Score: 2
    I used 25 instead of 26 though because Perl arrays are 0 based, and when starting with 0, the highest subscript is 25.
    @letters = ('a'..'z');
    print $letters[26];

    produces nothing.

    Well, of course it doesn't produce anything. However, you aren't use 26 as index. rand 26 will never produce 26, or anything larger than 26. rand 26 will produce something less than 26 - such that when rounded down to an integer, one gets at most 25. If you do int rand 25 the highest value you get is 24, and never 25. This is of course, spelled out in the manual.

    -- Abigail

  13. Re:Feature bloat in Perl by Abigail-II · · Score: 2
    Not to be pedantic, but that would only hold true for ASCII(ANSI, ISO-* etc) character systems. Not that there's too many people running PERL on EBCDIC systems ;-)

    We were discussing perl 5.6. EBCDIC support has been dropped in perl 5.6, making your remark not pedantic, but meaningless. From perldelta

    In earlier releases of Perl, EBCDIC environments like OS390 (also known as Open Edition MVS) and VM-ESA were supported. Due to changes required by the UTF-8 (Unicode) support, the EBCDIC platforms are not supported in Perl 5.6.0.

    -- Abigail

  14. Re:Lvaluable Subroutines by Abigail-II · · Score: 2
    mysub(2) = 15;
    Without looking at mysub(), how in the hell am I supposed to know this assigns to $a?

    You don't of course. But you have to realize that people will nowadays write that as:

    sub mysub {
    my ($f, $s) = @_;
    if ($f == 2) {$a = $s}
    ...
    }

    with equivalent code in C, Python, Java, whatever. And noone is whining "but how do I know it assigns to $a?

    Also realize that Perl has had functions returning lvalues for many years - substr, vec and pos have done so; with noone asking "but how do I know it assigns to something?" (hint: look at the assignment operator). All that's now happening is making something buildin available to the programmer.

    And the bottom line is: if you don't like it, don't use it.

    -- Abigail

  15. Re:Lvaluable Subroutines by Abigail-II · · Score: 2
    The variable $a is a "my" variable which means it is known only inside the package in which it is declared.

    You got that wrong. my variables are lexically scoped; they are only known to the block they are defined in. Packages are name spaces, and not lexical entities. my variables are unaware of package boundaries.

    -- Abigail

  16. Re:Feature bloat in Perl by Abigail-II · · Score: 2
    No, it's not obfuscated, it contains redundant code, and, worse, it's plain wrong. There are 26 letters in the alphabet, not 25. But we don't even need to know the number of letters in the alphabet, which means that if the change the set of characters to choose from, we don't need to update any other code.

    @letters = ('a' .. 'z');
    print $letters [rand @letters];

    -- Abigail

  17. Re:The Camel Book by Abigail-II · · Score: 2
    So needless to say, your money is still well invested.

    I disagree. The Camel isn't much more than a glorified dead tree version of the manual. But then a version that is 3.5 years and 3 versions out of date. Camel II documents perl 5.003. A lot has happened between 5.003 and 5.6. Perl isn't as stable as C which only gets a few small changes every couple of years. Each version of Perl adds a lot. There's hardly anything in the Camel II that isn't in the manual, and there is quite some stuff in the manual that isn't in the Camel. A PostScript version of the 5.005 manuals contained more than 1200 pages - each of them larger than a Camel page. And the manual for 5.6 is even larger than the one for 5.005.

    If you want to buy the camel, wait till later this year. Tom and Larry are busy writing the third edition. Real busy.

    -- Abigail

  18. Perlmonks.org? Site down due to Perl error. :-P by at-b · · Score: 2



    *cough*

    Hemos, did you actually check the Perlmonks link before putting it up? It's entire possible that the site has become so overloaded that it's caused their Perlscripts to freak and die, but it looks more like a simple configuration error.. when I went there, at 12:36pm GMT, I saw the following:

    --

    Software error:

    Can't use string ("") as a HASH ref while "strict refs" in use
    at /usr/local/lib/perl5/site_perl/5.005/Everything/HT ML.pm line 1550.

    --

    That looks like either a miscompilation or a bad configuration error. I hope the Perlmonk guys will manage to fix the problem ASAP - it's not often that your site gets the opportunity to be Slashdotted by so many geeks who are genuinely interested in Perl.

    Anyway, so what about PHP, then? ;-) (*duck*, *run*)

    Alex T-B

    PS: And no, this isn't meant to be a troll or flamebait against Perl. I genuinely like it. So there.
    PPS: I am just being told that the site has recovered. Ah, so Perl not only solves all problems, but can be fixed easily as well? Downloaditnow!

  19. Graphics Performance? by cr0sh · · Score: 2

    Has anybody here dealt with graphics performance under Perl? Specifically under X?

    I am wanting to undertake a project using X to develop a 3D engine (and I don't want to reinvent the wheel too much here, though I do want it to be a learning experience - I figure I will use OpenGL), and I am wondering if Perl can do this at a reasonable speed (I am not looking for 100 FPS with a bazillion texture mapped polys - though this would be cool). If not, what would be the best way?

    Should I do what I planned to do in the first place (using C/C++ and OpenGL), or is there a combo of using Perl and C/C++ I could/should do?

    Finally, what about handling non-standard devices (like custom home-brewed interface boards)? How can Perl handle those?

    I am just looking for advice so I don't head down the wrong road to find a dead end...

    --
    Reason is the Path to God - Anon
  20. perl still has features to add... by thogard · · Score: 2


    What I want in perl is a command like this:

    %cig=cgisplit;

    With everything else in perl why isn't this included. This single feature would save trillions of file opens every day. I don't need Include CGI if there was a decent cgisplit included.

  21. Re:Try CGI-Lite by thogard · · Score: 2

    All that 99.99% of cgi's need is simple way to parse the input which can be done in a very few lines of C that is about 1000 times faster than loading CGI-Lite.
    Sure I can use the "use CGI-Lite;" but the following works quite well:

    $query=$ENV{QUERY_STRING};
    read(STDIN, $query, $ENV{'CONTENT_LENGTH'}) if ($ENV{'CONTENT_LENGTH'} > 0);

    foreach (split(/&/,$query)) {
    ($name, $value) = split(/=/, $_);
    $name =~ tr/+/ /;
    $value =~ tr/+/ /;
    $name =~ s/%([A-F0-9][A-F0-9])/pack("C", hex($1))/gie;
    $value =~ s/%([A-F0-9][A-F0-9])/pack("C", hex($1))/gie;
    $cgi{$name}=$value;
    #print "$name = $value<br>\n";
    }

    So what does including something else get me that I need?

  22. Re:binary? by Emil+Brink · · Score: 2

    He, actually, I believe shaldannon was talking about the new support for binary integer literals added to 5.6.0. You can say stuff like 0b10000 and get 16, and so on. That'd be nice to have in C, actually. Too bad it didn't make it into C9X (the new updated C standard). Time for another GNU extension, perhaps? ;^)

    --
    main(O){10<putchar(4^--O?77-(15&5128 >>4*O):10)&&main(2+O);}
  23. Re:Feature bloat in Perl by reptilian · · Score: 2

    Perl is difficult to learn for anyone used to a different language with a more regular syntax, and this surely puts people off.

    You're joking, right? You shouldn't generalize so much. Two years ago, when I learned perl, I already know C/C++, Tcl, VB, and a host of other languages. Guess what? I took me TWO DAYS to learn enough about perl to use it with nothing but man perl and a telnet window.

    Maybe I'm a genius or something, but I doubt it. That it's hard to learn when you know other more structured languages is a claim I've never heard before.

    Man's unique agony as a species consists in his perpetual conflict between the desire to stand out and the need to blend in.

    --

    72656B636148206C72655020726568746F6E41207473754A

  24. Re:Well _I_ happen to like Perl. by G27+Radio · · Score: 2

    According to the article, in 5.6.0 the warning pragma replaces the -w flag. (I'm sure they didn't actually remove the -w flag when they added the warnings pragma.) Apparently the new pragma allows you to be more specific about which warnings you'd like to receive.

    use warnings;

    $a = @a[1]; # This generates a warning.

    {
    no warnings;
    $a = @a[1]; # This does not.
    }

    Anyway, I didn't see anyone specifically mention this in regard to the original post: With warnings turned on Perl informs you of variables that are only used once--which is greatly useful for finding capitalization errors in variables (or any mis-typed variable name.)

    Also, people can say whatever they want about Perl, but I love it. I can sit down an jam out code in seconds that would take me all day to do in most other languages--not that I'm exactly a whiz when it comes to other languages. A friend of mine wanted to write a poker-bot in C--I told him he'd be able to learn Perl and write it in Perl in less time than it would take him to write it in C. After he took my advice he agreed.

    Honestly I wish I were more proficient with C/C++, but the fact is I'm too lazy. So I'll stick with Perl since it does everything that I need it to do.

    numb

  25. Re:Lvaluable Subroutines by Baldrson · · Score: 2

    The variable $a is a "my" variable which means it is known only inside the package in which it is declared. You got that wrong. my variables are lexically scoped; they are only known to the block they are defined in. Packages are name spaces, and not lexical entities. my variables are unaware of package boundaries. True but since the typical use of packages puts one package per .pm file, the my variables are not only scoped (which, alone, addresses the original complaint) but scoped in a way that makes sense to the module author. If people want modular code, they can use modules. Let's not lose sight of the fact that the complaint lodged against Perl is really a complaint against the use of lvalues -- which is hardly a construct unique to Perl, and is a construct that has arguable merit if not abused.

  26. Bad HTML Formatting by Baldrson · · Score: 2
    Sorry, but Slashdot is stripping out my HTML formatting when I preview them.

    What a perverse bug.

    (I dare not preview this, but at least it will have some formatting.)

  27. Re:Lvaluable Subroutines by Baldrson · · Score: 2

    mysub(2) = 15; Without looking at mysub(), how in the hell am I supposed to know this assigns to $a? So much for the "black box." This violates just about every precept of good programming practice I can think of. Not that it won't be useful; in perl, anything can be useful... There are plenty of idiocyncracies in Perl to get quizzical about, but this isn't one of them. The variable $a is a "my" variable which means it is known only inside the package in which it is declared -- that is to say, it is inside the "black box".

  28. Re:Feature bloat in Perl by spiralx · · Score: 2

    To only look at Perl as a scripting language is to discount a lot of good and well implemented features in Perl.

    No, Perl was originally designed with a purpose in mind, and as with all projects, when it is taken beyond that purpose things start to get messy. If you want something more than a scripting language then you need to find something designed for that purpose, rather than a useful tool that has been pushed beyond its limits.

    I have used VB, C/C++, Python, RPG, COBOL, and Perl and I have not seen a language that wraps everything I need for systems administration and reporting, etc into one powerful package.

    Powerful, maybe, but elegant? Not really. Perl unfortunately wasn't initially designed to have a consistant mechanism for adding new features, and as such they have been added in a rather ad hoc manner. There's no reason why it shouldn't have the same features but in a more consistant manner.

    Perl is difficult to learn for anyone used to a different language with a more regular syntax, and this surely puts people off. Compare this with Python, which may not be quite as powerful, but has a consistant feel about it where new features can easily be added. Something like this is what Perl needs - consistancy and power together at last.

  29. Re:Feature bloat in Perl by bfree · · Score: 2

    The Pathelogically Eclectic Rubbish Lister may not have initially been designed with OO in mind, however it was designed and revised with the perl motto in mind "There's more than one way to do it". If you do not like a feature, don't use it and if you dislike the way a project is going you have the source and the choice to stop updating. Is your argument any different to the arguments against adding features to the linux kernel, it was never deisgned for xxxx so why add it now?

    --

    Never underestimate the dark side of the Source

  30. Re:Lvaluable Subroutines by IO+ERROR · · Score: 2
    oes the presence of unusual constructs mean that Perl code cannot be maintained?

    No, it doesn't. It just means you have to understand the constructs.

    Any language can be the source of unmaintainable code; it's up to us to use the power of the language in a sensible way.

    This is true. However, in all the Perl code I've written (some of it on fairly visible sites), I've taken pains to make sure I didn't use any of those unusual constructs, or to clarify them with comments if I found it necessary to use something weird.

    Your example (mysub(2) = 15) is unmaintainable, but I suspect most sensible coders would have called the function something clearer than "mysub". And if necessary they may even have put a clarifying comment next to it.

    This isn't my example; it came from the www.perl.com article. Funny that they should use such a bad example. I'd rather see good examples of how to put the language feature to use; they would be far more useful to me. But as for a clarifying comment, do I have to put one next to each invocation of mysub(), or should I just explain it at mysub() itself? What if I don't have the source for mysub()? Then I have to hope it's documented in the module documentation...

    I realize any feature of perl, or any other language, can be used for good or ill. This one just seems to be carrying a negative bias...
    ---

    --
    How am I supposed to fit a pithy, relevant quote into 120 characters?
  31. Regular Expressions improved by frankie_guasch · · Score: 2

    Perl regular expression engine has always been one of its best strong points. With the latest version the engine has now features never dreamed. Like a recursive pattern matching. If you have never used a programming language with hashes or regexpes, you think you don't need them. After using it with perl you'll wonder how have you been programming without it.

    1. Re:Regular Expressions improved by frankie_guasch · · Score: 2
      here You'll see an example about regular recursive expressions.

      $re = qr{
      \(
      (?:
      (?> [^()]+ ) # Non-parens without backtracking
      |
      (?p{ $re }) # Group with matching parens
      )*
      \)
      }x;

      That will match things like:

      abc(def(),ghi())

      If there are parens use the pattern recursed, if there aren't match !

  32. One potential use of lvalue subs by Matts · · Score: 3

    The Win32::OLE module has to do quite a few syntax changes to make it work like the VBScrypt or JScrypt implementations of OLE (the significance of this is in ASP use). However with lvalue subs this is no longer the case. Irritating VBScript things like:

    Object.Collection('Key') = Value

    Can now be implemented in perl using the very similar syntax:

    $Object->Collection('Key') = $Value;

    So I think lvalue subs will have a lot of uses. They will also go a long way to allowing overriding of all core functions, although that's still a way away yet (something python does far more elegantly than perl).

    --

    Matt. Want XML + Apache + Stylesheets? Get AxKit.
  33. Re:PERL FUTURE FORTH FUTURE = QUESTION by William+Tanksley · · Score: 3

    How many of you still program in FORTH?

    I do.

    And I disagree with every single thing you said there. I only had to read one book to understand Forth; furthermore, far from having a mess of inconsistent syntax, Forth has next to NO syntax.

    Forth doesn't make solving hard problems impossible; it makes writing application-specific languages easy. You can then solve your problem in a language which is natural for solving it -- and one which may not look very much like Forth. That's not even remotely possible in Perlish or Pythonic languages (outside of going to ridiculous lengths, like building a parser and parsing a seperate file or comments).

    Now, what does this have to do with Perl? I'm thinking that you're accusing Perl of being a fad, like Forth was in the early 80s. (And worse yet, a bad fad.) I don't think you have a leg to stand on here; not only did Perl manage to catch a MASSIVE growth spurt in the industry, but it has completely different characteristics from Forth in just about every way -- have you ever written a Forth compiler? How about a Perl compiler ;-)?

    Now, I'm sure that Perl will die out; it has nothing to offer that isn't done better in other places, and the sheer mass of its syntax is already causing it problems. Forth is still around, in OpenBoot and OTA (EuroPay), but only because it offered something really unique -- a simple VM which the programmer could understand and write to, without first having to master a byzantine language (I'm sorry, but even UCSD Pascal is byzantine compared to Forth).

    Perl seems popular among web monkeys and CS geeks. Forth is popular among engineers (I've also met a few mathematicians who like Forth, oddly enough).

    -Billy

  34. what's new in perl 5.6 by orabidoo · · Score: 3
    looking at the main new features of perl 5.6:
    • unicode support: it's a good thing, and not intrusive: it's off unless I "use utf8".
    • lvalue subs: not really important; I can see it being used in methods, i.e allowing $object->method = $value, rather than the usual $object->method("value")
    • improved threading, and win32 fork emulation. I dislike both threads and win32, so no comment. If peopel find it useful, it's good, I just hope it doesn't bloat perl too much when i'm not using it.
    • improved perl compiler: neat, I wish it got to the point where it's usable in practice, though. bytecode production and loading seems to be 'almost there'; I'm looking forward to them.
    • auto-vivification of filehandles: great. finally say goodbye to the Symbol::gensym kludge, for those cases where IO::* is just too heavy.
    • weak references: neat idea, annoying implementation. I mean, it needs support in the core, so why not just make it part of core and have a 'weaken' func, instead of needing a special module?
    • delete/exists on arrays: neat.
    • lexical warnings: cool.
    • 'our': I still think 'use vars' was perfectly good enough, and this is just added confusion.
    • v1.3.6 strings: kind of worthless.
    • large (>2GB) file support: good feature.
    • improvements in 'use fields', typed object refs and pseudo-hashes: the idea is to make objects look like hashes (with fields in $obj->{keys}), but be actually implemented as (faster) arrays, with compile-time checking of what field names actually exist. I'll be using this.
  35. Re:Unicode support by FigWig · · Score: 3

    Iconographic writing trades simplicity for portability. A system of writing wherein the rearrangements of the letters of the alphabet corresponds to the sounds (romantic languages for example) makes it impossible for a single word to make sense in different languages. Iconographic writing (chinese, japanese, etc) assigns a meaning to each character, but doesn't specify the sound. Thus the same writing can make sense to speakers of different chinese dialects (mandarin, cantonese, many others). Also the writing is accessible to Japanese & i believe korean, although each extends the icons with their own proprietary extensions. Makes sense if you were trying to make a unified script to manage your empire with if your empire extended over people with similar, but different languages.

    ps - IANAL (i am not a linguist)

    --
    Scuttlemonkey is a troll
  36. lvalues considered pain in ass by Bob+Ince · · Score: 3
    Sure, it's interesting, but it's yet more bizarre syntax that is going to be hell to debug.

    I agree. It's a feature that places more emphasis on the confusion between mutable objects and value types that seems to exist in most popular programming languages.

    The problem is variables: sometimes when you write them, they get evaluated immediately (print a), and sometimes they only represent a reference. Perl is extending the range of situations where the latter occurs by allowing these lvalues to be returned from subroutines. I'm also not greatly happy with the way you specify that a routine returns an lvalue in the header of the routine rather than in the return statement it actually affects; I see this causing many bugs.

    The solution in MOPL (My Own Pet Language) would be to make all variables objects, so that when you write their names it always means a reference to the object. And use constants instead of variables for holding immutable values to minimise use of variables.

    Some functional languages already solve the value/object problem quite elegantly. ...by not having mutables at all. Hmm.

    Anyway. I doubt this one'll tempt me to Perl; it's already got so many language features I haven't managed to learn yet, I don't need any more! Guess that's why I liked Python: I had picked it up, learned the language features, and starting writing production code in less than half an hour. But hey, I wouldn't want to start a Perl/Python flame war or anything. ;-) (After all, Python causes as much object-value confusion as any other language, when lists are mutables but tuples are not.)


    --
    This comment was brought to you by And Clover.
  37. Feature bloat in Perl by spiralx · · Score: 3

    Am I the only one who thinks that the Perl team are trying too hard to make Perl all things to all programmers? I mean, Perl was designed to do simple scripting and text processing tasks, which it does well, but each new release sees some new "feature" tacked on to the end of the language without any real care over whether it is actually required or not.

    Perl was never designed to handle classes, threading, lvalue subroutines and so on. I can understand the need for Unicode support - this is in keeping with the whole "Practical Exraction and Report Language" thing, but the rest seems unnecessary for what Perl should be. And unfortunately, Larry Wall et al., haven't never considered these issues in the first place, have added them to the language with little or no care or elegance.

    What Perl needs is a bit of a rethink - go back to the core of what it is supposed to do and make sure that it does that as easily as possible. It doesn't need object orientation or threading - they are extraneous and bloated. Unfortunately, at the rate Perl's bloat is increasing, it'll soon be the Visual Basic of the *nix world, with plenty of "cool features" that nobody needs.

    1. Re:Feature bloat in Perl by buzzcutbuddha · · Score: 3

      To only look at Perl as a scripting language is to discount a lot of good and well implemented features in Perl. Just because you don't need them does not mean that no one needs that feature. If there is a need for a feature, why not include it?
      I have used VB, C/C++, Python, RPG, COBOL, and Perl and I have not seen a language that wraps everything I need for systems administration and reporting, etc into one powerful package.
      And as far as threading is concerned, Perl is using threading in Win32 to allow ActivePerl emulate the fork command from *nix. That is something that should exist (free-threading is available in VC++ for all Win32 platforms), and I'm glad that I finally have it at my disposal.
      Anyway, a rethink of Perl has been underway for a while. Look up the Topaz project.

    2. Re:Feature bloat in Perl by Matts · · Score: 4

      I think you're not the only one, judging by the python luvers who have moderated you up ;-)

      But are you saying that a language designed to do one thing should forever remain just to do that one thing?

      You think perl's OO features aren't elegant. I think the opposite - they so neatly fit into the language that it's hard to believe that they are so simple (bless $ref; # whoaa - it's an object now).

      Perl does need a _bit_ of a rethink, but that rethink won't be to reduce perl back to just a reporting language - it will be to make perl more powerful. To provide threading or multiple interpreters from the ground up. To provide exceptions built into the core. To make compiled extensions a bit easier. To make classes have named attributes (not the monstrosity that is "use fields"). To make signal handling safe.

      These things are being thought about, and are being dealt with, but don't expect miracles any time soon.

      --

      Matt. Want XML + Apache + Stylesheets? Get AxKit.
    3. Re:Feature bloat in Perl by jbert · · Score: 5

      I'm not surprised you think this if you look at perl as the "Practical Extraction and Report Language". Or as 'just' a sysadmin tool.

      What perl is today is the ultimate glue language. Via the modules available (both those shipped with perl and those available via CPAN) you can interface to practically anything (Most network protocols, data formats, APIs, etc etc)

      To be honest, 'bloat' in the language is only important for two things:

      1) Performance. This is fair enough, lighter interpreted languages will (probably) start up faster. Once the interpreter is running, though, I don't see why an (unused) language feature will impact execution speed.

      Also, "premature optimisation is the root of all evil". Most perl scripts are 'fast enough'. Those that are performance sensitive (e.g. CGI under Apache) can generally be speeded up (apache mod_perl).

      2) Language breadth. This issue seems to be alluded to by people elsewhere in this dicussion. The mindset appears to be "if a feature is in perl then I'll have to learn it to be able to maintain perl". I can understand why feature bloat is a worry if you think this.

      Perl has a huge feature set. The key thing to understand is that you DON'T NEED TO KNOW THE WHOLE LANGUAGE (sorry for shouting, its my main point and this is a long comment - wanted to make it stand out ;-). I think there is a Larry Wall quote along the lines of "Perl's learning curve isn't steep, but it is long".

      The point here is that you don't need to know that there is a language feature which will do your job in one line. If you know, you'll use it. If you don't know, you'll write 10 lines of perl instead. (or 50 or so in C to do the same job).

      If you are maintaining someone else's code and they use a feature you don't recognise then you may need to look that up (the docs are good + install with perl). But the set of features you need to know is still not the whole language, its just the set of features which the author used.

      Lastly, the number of features which can be abused to write unmaintainable code isn't really relevant. If a coder is sadistic enough to write unmaintainable code they only really need one or two language features (which all languages have).

      Perl is not a panacea. However, instead of thinking "use the (one) right tool for the job" and learning C, C++, perl, python, java, scheme, eiffel etc, use "a good enough tool for the job" - which is often perl. Its easier to write in perl all the time and use a new feature than it is to learn a whole new language for every task.

      Phew. Rant over.

  38. Lvaluable Subroutines by IO+ERROR · · Score: 3
    This isn't intended as flamebait, though it might sound like it. That said, I'm trying to grok these new features...

    From the department of bizarre syntax, subroutines can now be legal lvalues; that means they can be assigned to. Of course, this only works if they return something assignable, and if they're marked as an lvalue subroutine.

    Took me a few minutes, but I finally got my head around this one. Sure, it's interesting, but it's yet more bizarre syntax that is going to be hell to debug.

    mysub(2) = 15;

    Without looking at mysub(), how in the hell am I supposed to know this assigns to $a? So much for the "black box." This violates just about every precept of good programming practice I can think of. Not that it won't be useful; in perl, anything can be useful...

    This is yet one more reason I am going to stay as far away from perl as I possibly can. I like to be able to maintain my code. And sometimes I have to maintain other people's code. Things like this will make maintenance a complete nightmare.
    ---

    --
    How am I supposed to fit a pithy, relevant quote into 120 characters?
    1. Re:Lvaluable Subroutines by ratbag · · Score: 5

      Does the presence of unusual constructs mean that Perl code cannot be maintained?

      We often see the accusation that Perl is unmaintainable: I suspect that the blame lies with the coders, rather than the language itself.

      Perl has a very handy construct that can render almost all code highly maintainable:

      #
      # it looks like this
      #


      Any language can be the source of unmaintainable code; it's up to us to use the power of the language in a sensible way.

      Your example (mysub(2) = 15) is unmaintainable, but I suspect most sensible coders would have called the function something clearer than "mysub". And if necessary they may even have put a clarifying comment next to it.

      Rob. (C++ and Perl coder, with an occasional dash of Python - Zope rules!)

  39. Re:More confusion by henley · · Score: 4

    I know I ought to leave this one alone.. I mean the clue is in the misspelling of the One True Religion...er....language name.

    But it does allow one to re-iterate the point of the language:

    Perl - The Swiss Army Chainsaw of Languages

    If you want "clean", "pure" or "compact", move along there's nothing to see here. If, however you're a bit of a divv, programming wise (I'd certainly own up to this one), and/or you don't get the time you might like to code those C/C++ monster environments, and/or you have a job to do *now*, then the extreme feature-itis of Perl may well be for you...

    Perl is *definitely* from the same stable of thought that brought you the UNIX environment - give 'em a toolkit and let 'em write their own apps... Except this time the toolkit is embedded within a language, which makes it usable on many platforms.. I've written scripts on AIX which I was able to successfully port to Linux, NT and even OS/2 using a simple "translation" tool - FTP. No source code editing for me, oh no.

    And now if you excuse me I note that since I can now run Perl on my Psion, I feel the need for some serious mobile scripting coming on.

    With apologies to the rest of the /. crowd for feeding the troll....

    --

    --
    I'd rather have a bottle in front of me than a frontal lobotomy
  40. Well _I_ happen to like Perl. by zCyl · · Score: 5

    I've been coding for about 15 years, but never bothered to learn Perl until a few weeks ago. I can tell you I'm sufficiently impressed with the language. Certainly, it has the power to be cryptic, but it's not as if "features" of other languages don't offer you an equivalent level of too much power (e.g. #define, the champion of obfuscated C/C++ contests).

    So why do I like perl? Because it has many of the most useful language constructs integrated into its general semantics in a way that other languages don't. In Java you can declare a stack object, in C++ w/ STL you can easily declare a stack object, but in perl, you just use push and pop and the stack is there. In perl if you want to treat something as a stack, and then as a queue, and then as an array, it's elementary.

    Anyone who has ever looked at a unix configuration file can't dismiss the usefulness of perl's split function, and the simplicity it provides by splitting files into lines, lines into subsections, and sticking it all in arrays, stacks, or queues with arbitrary lengths, and all done with no effort, and a tiny section of code, in perl.

    I shouldn't even need to mention the potential beauty and simplicity of regular expressions (in the hands of someone who knows how to comment!). In my most recent application I needed to split the unix mail spool file into separate emails, it was elementary using regular expressions in perl, since I could make one regular expression to detect the well-structured From line at the beginning of each email. The corresponding C/C++ code would have been quite large and complicated, and the corresponding Java code would have taken 14 packages, 32 regular methods, and 704 getter/setter methods.

    The other great thing about Perl is that because of the way things like split, foreach, etc are so naturally integrated, you can usually avoid the most common programming errors. After 15 years, the things that still trip me up in a program are the stupid things. A null pointer error while traversing a data structure, or an off-by-one error while comparing something or interating something. You can't have an off-by-one with split or with regular expressions, since Perl handles the grunt work for you. You basically just tell it what you want it to do in condensed form, and it figures it out.

    My biggest gripe with perl is that there seems to be no mode to require variables to be declared beforehand. I really despise when I'm coding and do something like:

    my ($fileName) = "/etc/blah/blah.cfg";
    if ( $filename =~ m~^/etc~ ) { print "This is in /etc\n");

    In most languages, this would trigger a compile error since filename has never been declared, and you would say, "Oh, whoops, I meant to put fileName there", but since perl lets you declare filename in the middle of the if statement, it just makes a new variable. Fine, if you want to program in basic this is useful, but I want to turn it off because I prefer to maintain my sanity. If anyone knows a way to do this, please post it.

    All in all, perl is a promissing language. I don't expect it to take any flying leaps in popularity or make any great paradigm shifts due to the level of detest some people have for it, but I know I'll continue to use it for the things it is well tuned for. It's the best tool for a great number of jobs.