Slashdot Mirror


Perl, Perl 6, and Two Application Frameworks Release 2017 Advent Calendars (perladvent.org)

An anonymous reader writes: Friday saw this year's first new posts on the Perl Advent Calendar, a geeky tradition first started back in 2000. It describes Santa including Unicode's "Father Christmas" emoji by enabling UTF-8 encoding and then using the appropriate hexadecimal code.

But in another corner of the North Pole, you can also unwrap the Perl 6 Advent Calendar, which this year celebrates the two-year anniversary of the official launch of Perl 6. Its first post follows a Grinch who used the but and does operators in Perl 6, while wrapping methods and subroutines to add extra sneaky features, "and even mutated the language itself to do our bidding."

Perl/Python guru Joel Berger has also started an advent calendar for the Mojolicious web application framework (written in Perl), and there's apparently also an advent calendar coming for the Perl Dancer web application framework.

38 comments

  1. Perl by Anonymous Coward · · Score: 0, Funny

    Is worse than Hitler.

    1. Re:Perl by Hal_Porter · · Score: 1

      At least it seems like it's getting somewhat decent Unicode support. I remember writing a Perl script to strip out stuff from something because reasons.

      my $hyphen = '-';
      my $delim_len = length($hyphen);
      my $index=rindex($foo, $delim);
      if ( $index != -1 )
      ...

      Why the awkward $delim_len? Because if the hyphen is a U+ 2013 EN DASH the length is 2. If it's a regular ASCII hyphen it's 1. And the only reason I'm stripping them out is because they cause problems later.

      You expect this sort of thing in C because strlen returns a length in bytes because it was invented in the 1970s, but it kind of sucks for a scripting language.

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    2. Re:Perl by arth1 · · Score: 1

      Why the awkward $delim_len? Because if the hyphen is a U+ 2013 EN DASH the length is 2.

      But then it isn't a hyphen.

      Decouple your mind from visual representations.
      In perl, there are even special functions and methods for handling separators, making it very easy to use any delimiters or set of delimiters you define. The typical way to handle this would be with split and join.

    3. Re:Perl by Hal_Porter · · Score: 1

      But then it isn't a hyphen.

      Yeah, I changed the variable name when I was bowdlerizing the code. And broke it, because I'm sloppy.

      Well but the deeper point is that Perl - at least the version I was using then - didn't properly support UTF-8. length($delim) returned the number of bytes like strlen in C by default.

      Meanwhile trying the same thing in Python. All the dashes in my code at EN DASHes which Slashdot won't let me post.

      foo='-'
      print ( len(foo) )

      prints 1 as even if foo is a EN DASH.

      Mind you, just now I tried this

      use utf8;
       
      my $d = '-';
      my $d_len = length($d);
      print $d_len;
      print $d

      Without the use utf8; line I get 3 when $hyphen is a EN DASH With it I get 1. It still complains about "Wide character in print".

      A bit of Googling turns up binmode as the way around this. I.e. to get rid of the complaint I can do

      use utf8;
      binmode STDOUT, ":utf8";
       
      my $d = '-';
      my $d_len = length($d);
      print $d_len;
      print $d

      I.e. Perl 5 is a bit clunky for this stuff because by default it runs in a mode which isn't UTF-8 aware probably for compatibility reasons. You need to turn on support for utf8 strings in the string functions and utf strings in stdout and probably in other places too.

      You can see how non automatic it is because slashdot, which is written in Perl, is pretty much guaranteed to corrupt unicode characters in comments even though slashdot is is utf8.

      Of course Python doesn't have these issues. Then again Python doesn't really care about back compatibility - they probably turned on UTF aware mode at some point and just told people to suck it up if that broke their scripts.

      Still these days I prefer Python to Perl. And not just or even primarily the UTF stuff - there's loads of useful things available to Python code for data manipulation like numpy I really like. Could I do the same thing in Perl? Yeah, I'm sure I could. It'd just take longer.

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    4. Re:Perl by arth1 · · Score: 4, Informative

      You can see how non automatic it is because slashdot, which is written in Perl, is pretty much guaranteed to corrupt unicode characters in comments even though slashdot is is utf8.

      Slashdot had UTF-8 support for a short while a decade or so ago. It was turned back off again, because the perl support was too good, allowing things like right-to-left spaces, which the crowd here naturally pounced on.
      Turning it back on is easy enough, but unless someone spends a lot of time hardening the system, it will get abused again.

      As for your perl em-dash problem, why do you need to know the length, if it's a separator? Use the built-in functions that can deal with a separator of any length, and you should not have to write specific handling.

    5. Re: Perl by silverdirk · · Score: 1

      I see people complain about this from time to time, but I dont agree. Perl scripts often process binary data and if you assumed UTF-8 on input and output then it would break things like unzipping compressed data on stdin or streaming it to stdout. The unix tradition perl is built on assumes bytes until you tell it otherwise.

      I dont follow python, but Id assume you get the exact opposite problem, needing to turn on binary mode any time your script might need to stream binary data?

      Meanwhile, I am rather annoyed at slashdots lack of unicode. It would be nice if they could at least support the common characters used by i.e. the iOS screen keyboard which makes it impossible for me to use apostrophes.

      --
      Mark of the Coder fades from you. You perform Opening on World of Warcraft. Warcraft crits GPA for 4. GPA dies.
  2. Perl 7 by Anonymous Coward · · Score: 0

    Will Perl 7 be based on Perl 5 or Perl 6?

    1. Re:Perl 7 by Anonymous Coward · · Score: 0

      No.

  3. Re:Gay Sex by Anonymous Coward · · Score: 1

    If you weren't retarded you would learn pearl instead of Python & go
     
    -=}BeauHD{=-

  4. ACs hate it by DCFusor · · Score: 2

    Real programmers just use it to get 'er done. I guess you feel embarrassed enough to want to hide your identity while displaying ignorance and intellectual laziness.

    --
    Why guess when you can know? Measure!
    1. Re:ACs hate it by NoNonAlphaCharsHere · · Score: 2, Funny

      Oh please. The only way perl could be more write-only was if there was a requirement that you carve it in granite.

    2. Re:ACs hate it by DCFusor · · Score: 4, Insightful

      Bad programmers can create write-only code in any language...I could name a few that are worse than perl, since they copied the regular expression engine and too-clever-by-half beginner people abuse the snot out of it. Is that what you mean? I don't know anyone who has troubles reading and maintaining my code in any language. Hmm...maybe it's not the language.

      --
      Why guess when you can know? Measure!
    3. Re: ACs hate it by Anonymous Coward · · Score: 2, Interesting

      I havenâ(TM)t seen Perl in a long time but canâ(TM)t imagine itâ(TM)s never evolved into something which is basically the same as everything else by now.

      I have to admit the reason I donâ(TM)t bother with Python is that so far, most Python code Iâ(TM)ve seen has been Write-Only because just like Perl and PhP, the people writing most of the code in it has been âoeI donâ(TM)t want to learn to program, I just wanna do stuffâ.

      In the old days, it was BASIC, Visual Basic, sed and awk. I think that no matter what the individual merits of a programming language, generally languages that oversimplify the process of starting with a two line program and stringing together spaghetti after, it generally creates a toxic culture for the language.

      Consider this, if you search for answers to questions in Python, PHP or Perl, youâ(TM)ll almost always receive answers from coders not programmers. The result is code that gets the job done, but has absolutely no interest in doing it well.

    4. Re:ACs hate it by NoNonAlphaCharsHere · · Score: 2

      "Bad programmers can write bad programs" is a tautology. The problem with perl is that it makes it (really) hard for good programmers to make (and MAINTAIN) good programs.

    5. Re: ACs hate it by DCFusor · · Score: 1

      Mod parent up. Most people oversimplify the issues here. A carpenter may not be a good architect - the reverse is also true, few get both right. The vanity titles get tossed around far too much in lieu of pay and real perks.

      --
      Why guess when you can know? Measure!
    6. Re:ACs hate it by Anonymous Coward · · Score: 0

      "Bad programmers can write bad programs" is a tautology. The problem with perl is that it makes it (really) hard for good programmers to make (and MAINTAIN) good programs.

      I have been using perl5 for past 15years and see no such problem. I still use it for new Projects.
      I don't think the person even knows any perl to make such a comment.

    7. Re: ACs hate it by BKX · · Score: 1

      I'll second that. I once tried to understand what was going on in get_iplayer. It was completely opaque. Regexes can suck my ass. I spent several days trying to figure something out (I don't remember what I was trying to do) to no avail. I ended up giving up. To be fair, I'm not a professional programmer, but I don't often struggle that much with source code. I swear, every time I have trouble like that it's been with perl or with c++ when someone gets creative.

    8. Re:ACs hate it by arth1 · · Score: 3, Interesting

      "Bad programmers can write bad programs" is a tautology.

      No, it isn't. Linguistically there's nothing tautological about "A can B", no matter what the relation between A and B is.

      The problem with perl is that it makes it (really) hard for good programmers to make (and MAINTAIN) good programs.

      There are many problems with perl, but unless you define what a "good program" is, this is meaningless.
      Perl gives programmers more rope than most languages. How they use that rope is up to them.

    9. Re: ACs hate it by Anonymous Coward · · Score: 0

      Mod grandparent down for posting line noise puncuation from an Iapple device. Fix your crap.

    10. Re:ACs hate it by eddeye · · Score: 1

      Bad programmers can create write-only code in any language...I could name a few that are worse than perl, since they copied the regular expression engine and too-clever-by-half beginner people abuse the snot out of it. Is that what you mean? I don't know anyone who has troubles reading and maintaining my code in any language. Hmm...maybe it's not the language.

      You can cut off your foot with a scalpel or a chainsaw - but one of them makes it a lot easier to do accidentally.

      With strict discipline a good programmer can write good programs in any language. But most programmers aren't good programmers. Even most good programmers don't have great discipline. We all get lazy, slip up, eyes glaze over after too many hours staring at the screen, make a mental error.

      A tool with more safety features to prevent stupid mistakes will usually, in fact, prevent more stupid mistakes. A language with fewer hidden side effects and magic variables/expressions is generally better at preventing such things. Python is far superior to Perl in this regard.

      So while you may be the World's Greatest Programmer, safer languages make life easier for the rest of us mere mortals. A good programmer doesn't take 100 yards of rope when 10 feet with do. Use the right tool for the job. Perl is good for some niches but better options are usually available.

      --
      Democracy is two wolves and a sheep voting on lunch.
    11. Re:ACs hate it by Anonymous Coward · · Score: 0

      Oh please. The only way perl could be more write-only was if there was a requirement that you carve it in granite.

      Wouldn't that make it more read-only, not more write-only?

    12. Re: ACs hate it by silverdirk · · Score: 1

      I will swear by Perls ability to let me write more features in less time, with test cases and documentation, which is easier to maintain than any other language Ive used extensively (C++, C, Delphi, Java, Javascript, Bash)

      Ive done a little Python and a little Ruby, and both were prettier to look at, but the toolchains were not as well developed for general purpose agile tinkering at the time I used them. Its hard to make a fair comparison though without delving as deep into those as ive done with perl.

      --
      Mark of the Coder fades from you. You perform Opening on World of Warcraft. Warcraft crits GPA for 4. GPA dies.
  5. How to tell if you've been using perl too long by NoNonAlphaCharsHere · · Score: 5, Funny

    If you see cartoon swearing, like "?#@*&%!" and think to yourself "That's silly, he should have used "#@$_" instead, it's more efficient", you're been using too much perl.

  6. It could be alot worse by Anonymous Coward · · Score: 0

    I initially read that as "Men of the Perl.org 2018 Calendar"

  7. AC here. I love Perl by Anonymous Coward · · Score: 0

    I do get the humor. I'm AC because I only give out my cookies sparingly (actually: kudos to /. for allowing such dinosaurs to post, really). If it were possible to have an ID on /. without cookies, I would have been in for long time. Alas...

    AC and I love Perl? Someone's head exploding now?

    1. Re:AC here. I love Perl by DCFusor · · Score: 1

      No explosions here. It's just that most of the really nasty trolls - who never seem able to actually back up their crap - are also AC for reasons other than the cookie issue.

      --
      Why guess when you can know? Measure!
  8. Mormans are cool by Anonymous Coward · · Score: 0

    but only if they have multiple wives.

  9. He obviously stealing Christmas, but ... by fahrbot-bot · · Score: 1

    Its first post follows a Grinch who used the but and does operators in Perl 6 ...

    ... it's nice to see someone using Perl 6.

    --
    It must have been something you assimilated. . . .
  10. Perl6, brought to you by PHP by Rutulian · · Score: 1

    Someone has a good sense of humor. The Perl6 advent calendar is hosted on a Wordpress site.

    1. Re:Perl6, brought to you by PHP by iggymanz · · Score: 1, Redundant

      PHP may be a sloppy language that encourages buggy low-quality work such as Wordpress & modules....but you think anyone actually uses Perl 6 for anything? pfffft, Larry screwed around too long, the world at large has left it behind.

    2. Re:Perl6, brought to you by PHP by Rutulian · · Score: 1

      Perhaps. I haven't had time to mess around with it yet, but I've been meaning to. The problem is Perl6 is a clean break from Perl5, so it is only useful for new projects. If you are working with legacy code, you have to stick with Perl5. And there are also a ton of useful packages that are not yet available for Perl6.

      Also, while Larry did screw around a bit, the delay wasn't entirely his fault. There were a few groups writing competing specs/implementations, and rewriting them, before they finally settled on Larry's spec and the Rakudo implementation.

    3. Re:Perl6, brought to you by PHP by piojo · · Score: 1

      It has potential. Perl 6 is full of good ideas, so I started using it for a small project. Don't think of it as perl--it is something new, and it hasn't gained big popularity yet. It's not a new version, it's a new language. If they'd called it P++ instead of Perl 6, it would have been a more accurate description.

      --
      A cat can't teach a dog to bark.
    4. Re:Perl6, brought to you by PHP by iggymanz · · Score: 1

      it's too complex when other languages can do the same job with a fifth or less the syntax, Larry and co. went crazy and threw in everything and the kitchen sink

    5. Re:Perl6, brought to you by PHP by piojo · · Score: 1

      it's too complex when other languages can do the same job with a fifth or less the syntax, Larry and co. went crazy and threw in everything and the kitchen sink

      I have sympathy for that viewpoint, but it's no more complex than C++ (including the two most common libraries), but it does a lot more with less library use and boilerplate. It took me a month to feel comfortable with Perl 6. A lot of that "kitchen sink" stuff is really useful. gather/take iteratively builds data structures. emit/tap is for event handling. Junctions and parallel loops are just plain awesome. But each feature seemed unnecessary until I needed to use it. I'd advise against making a firm judgment without using Perl 6 on a project, or at least analyzing how its features would be used on a project. (I still use the old perl for little scripts, especially those that need to be dead reliable.)

      --
      A cat can't teach a dog to bark.
    6. Re:Perl6, brought to you by PHP by iggymanz · · Score: 1

      You made me laugh with that, as a former C++ dev you picked the one language that is the extremely pathological case of bad architecture. Using that as example is saying "well georgie the birthday pedo clown here isn't so bad, just look at Jeffery Dahmer who ate his victims"

    7. Re:Perl6, brought to you by PHP by piojo · · Score: 1

      We may have different metrics. I chose a language that's highly effective and widely used. Its design obviously isn't bad enough to keep people from using it. I didn't cherry-pick it, either. I could have named Haskell as an example of difficulty and theoretical simplicity hampered by conceptual complexity. I have other complaints about Python, Ruby, and Java, so I wouldn't use them as examples in language comparisons. C# is nice but not syntactically expressive and with a weak class/inheritance model. C++ is a damn useful language, despite its warts.

      --
      A cat can't teach a dog to bark.
  11. Perl dying by synaptic · · Score: 1

    Perl seems to be dying. Everybody loves bash again now, and python, go, node.js, etc..

    A big miss by the Perl community was not getting AWS Lambda support or an AWS module for a long time. Boto ate Perl's lunch.