February 2013 Archives

A follow up on three-value logic in Perl

So far the initial response to my three-value logic in Perl post has been great. Due to that response, on Reddit, Perlmonks, here and my RT queue has led to:

  • Made sorting a bit more useful
  • Contemplating removing stringification
  • Plenty of strengthening of the documentation (including making it explicitly clear that the unknown logic is akin to SQL's NULL)

And then there's been some interesting rebuttals.

Three-value logic in Perl

Bad news. You've a brand-new CEO and he has a reputation for having a short temper. He knows about his reputation so he's decided to win over the employees by offering all "underpaid" employees a salary increase of $3,000 per year. You've been tasked to write the code. Fortunately, it's fairly straight-forward.

foreach my $employee (@employees) {
    if ( $employee->salary < $threshold ) {
        increase_salary( $employee, 3_000 );

Congratulations. You just got fired and have to find a new job. Here's what went wrong and a new way to make sure it doesn't happen again.

Red-Black Trees in Perl 6 Explained

I've started digging around with Perl 6 again and I'm quite pleasantly surprised. As you can see, Perl 6 is just about feature-complete. The main obstacle to using it is probably performance. When I previously checked it was 20 times slower than Perl 5, now it's only 4 times slower and catching up rapidly (update: this information was from a conversation at FOSDEM and appears to not be correct. Perl 6 is still much slower. I will try to track down more information). Jonathan Worthington's port to the JVM is going well and Nick Clark mentions that initial tests on one (admittedly small) benchmark show it significantly faster than Perl 5!. With Perl 5 already being the fastest widely used dynamic language, this might be the key to Perl 6 being ready for prime time.

Currently Jonathan hopes to allow NQP (Not Quite Perl) to cross-compile itself to the JVM within a month and hopefully have Rakudo on the JVM in a "good state" before the summer conference season. He stresses that this is a an estimate, not a guarantee. Also, it appears to be more of an exploration of how well the JVM will cope with this sort of language (my words, not his).

Given the exciting developments, I decided to start taking a serious look at Perl 6 again. I read the red-black tree implementation in Perl 6 and decided to write up an explanation to both help you see what Perl 6 can do and to refamiliarize myself with the language. Please don't be discouraged by how complicated some of the explanation will sound: red-black tree implementations can be a bit daunting for someone who's never delved into them before. In fact, most of your Perl 6 code will be fairly straight-forward. This example is deliberately chosen because of the diversity of different features it uses to create something very powerful.

Now let's get a brief understanding of what red-black trees are.

Perl 7 - Final Thoughts

First, I want to apologize. My follow-up to the Perl 7 post was not very polite. When I predicted that "nothing" would happen, even if people wanted it, I could have said that in a much kinder way. In particular, my apologies to Ricardo for that.

As for "Perl 7", let me be clear: I don't support it. I originally asked the question because I wanted to know what people thought and instead of kicking over a rock to see what was underneath, I kicked over a hornets nest. More importantly (to me), I got my answer in spades.

My Prediction

Yesterday's post has touched off the version number debate again and not everyone is happy about that. Ricardo Signes, the current pumpking, appears to have said no, we're not going to do anything. chromatic has also dismissed the idea immediately.John Napiorkowski is also opposed to it.

Meanwhile, Joel Berger seems keen on addressing this issue, Johan Vromans also seemed to dispute the notion that a new version has no benefit. And Peter Rabbitson, in response to the claim that a new version is akin to the Emperor's New Clothes (my words, not the original author's) wrote:

The problem (as I see it) is that while we as an echo chamber don't have anything new to offer compared to 5.10 (roughly speaking), the wider world never looked past 5.6. This is an effort to fix that (and only that). Did linux 3.0 have anything new to offer? We can even "blame Linus" for the reasoning behind such a jump.

Looking at all of this, I have a small prediction to make.

Perl 7

At the risk of starting a massive flame war, I have only one question: what are the pros and cons of releasing Perl 5.20.0 as Perl 7.0.0?

About Ovid

user-pic Have Perl; Will Travel. Freelance Perl/Testing/Agile consultant. Photo by http://www.circle23.com/. Warning: that site is not safe for work. The photographer is a good friend of mine, though, and it's appropriate to credit his work.